本文整理汇总了Java中javax.accessibility.AccessibleText.getIndexAtPoint方法的典型用法代码示例。如果您正苦于以下问题:Java AccessibleText.getIndexAtPoint方法的具体用法?Java AccessibleText.getIndexAtPoint怎么用?Java AccessibleText.getIndexAtPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.accessibility.AccessibleText
的用法示例。
在下文中一共展示了AccessibleText.getIndexAtPoint方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mouseClicked
import javax.accessibility.AccessibleText; //导入方法依赖的package包/类
@Override
public void mouseClicked(MouseEvent e) {
Point point = e.getPoint();
AccessibleText at = (AccessibleText) label.getAccessibleContext();
int pos = at.getIndexAtPoint(point);
AttributeSet as = at.getCharacterAttribute(pos);
if (label.isEnabled() && as.getAttribute(HTML.Tag.A) != null) {
label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
SimpleAttributeSet attr=(SimpleAttributeSet)as.getAttribute(HTML.Tag.A);
String href=(String)attr.getAttribute(HTML.Attribute.HREF);
fireActionPerformed(
new ActionEvent(label,ActionEvent.ACTION_PERFORMED,href));
} else {
label.setCursor(Cursor.getDefaultCursor());
}
}
示例2: mouseMoved
import javax.accessibility.AccessibleText; //导入方法依赖的package包/类
@Override
public void mouseMoved(MouseEvent e) {
Point point = e.getPoint();
AccessibleText at = (AccessibleText) label.getAccessibleContext();
int pos = at.getIndexAtPoint(point);
AttributeSet as = at.getCharacterAttribute(pos);
if (label.isEnabled() && as.getAttribute(HTML.Tag.A) != null) {
label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
} else {
label.setCursor(Cursor.getDefaultCursor());
}
}
示例3: getIndexAtPoint
import javax.accessibility.AccessibleText; //导入方法依赖的package包/类
/**
* Given a point in local coordinates, return the zero-based index of
* the character under that Point. If the point is invalid, this method
* returns -1.
*
* @param p
* the Point in local coordinates
* @return the zero-based index of the character under Point p; if Point
* is invalid return -1.
*/
public int getIndexAtPoint(Point p) {
AccessibleText at = getNoteLabelAccessibleText();
if (at != null && sameWindowAncestor(pane, noteLabel)) {
// convert point from the option pane bounds
// to the note label bounds.
Point noteLabelPoint = SwingUtilities.convertPoint(pane, p, noteLabel);
if (noteLabelPoint != null) {
return at.getIndexAtPoint(noteLabelPoint);
}
}
return -1;
}