下面列出了javax.swing.plaf.nimbus.NimbusLookAndFeel#javax.accessibility.Accessible 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
static int[] getSelectedTextRange(final Accessible a, final Component c) {
if (a == null) return new int[2];
return CAccessibility.invokeAndWait(new Callable<int[]>() {
public int[] call() {
final AccessibleContext ac = a.getAccessibleContext();
if (ac == null) return new int[2];
final AccessibleText at = ac.getAccessibleText();
if (at == null) return new int[2];
final int[] ret = new int[2];
ret[0] = at.getSelectionStart();
ret[1] = at.getSelectionEnd();
return ret;
}
}, c);
}
static int[] getVisibleCharacterRange(final Accessible a) {
final Accessible sa = CAccessible.getSwingAccessible(a);
if (!(sa instanceof JTextComponent)) return null;
final JTextComponent jc = (JTextComponent) sa;
final Rectangle rect = jc.getVisibleRect();
final Point topLeft = new Point(rect.x, rect.y);
final Point topRight = new Point(rect.x + rect.width, rect.y);
final Point bottomLeft = new Point(rect.x, rect.y + rect.height);
final Point bottomRight = new Point(rect.x + rect.width, rect.y + rect.height);
int start = Math.min(jc.viewToModel(topLeft), jc.viewToModel(topRight));
int end = Math.max(jc.viewToModel(bottomLeft), jc.viewToModel(bottomRight));
if (start < 0) start = 0;
if (end < 0) end = 0;
return new int[] { start, end };
}
static int[] getVisibleCharacterRange(final Accessible a) {
final Accessible sa = CAccessible.getSwingAccessible(a);
if (!(sa instanceof JTextComponent)) return null;
final JTextComponent jc = (JTextComponent) sa;
final Rectangle rect = jc.getVisibleRect();
final Point topLeft = new Point(rect.x, rect.y);
final Point topRight = new Point(rect.x + rect.width, rect.y);
final Point bottomLeft = new Point(rect.x, rect.y + rect.height);
final Point bottomRight = new Point(rect.x + rect.width, rect.y + rect.height);
int start = Math.min(jc.viewToModel(topLeft), jc.viewToModel(topRight));
int end = Math.max(jc.viewToModel(bottomLeft), jc.viewToModel(bottomRight));
if (start < 0) start = 0;
if (end < 0) end = 0;
return new int[] { start, end };
}
static int[] getSelectedTextRange(final Accessible a, final Component c) {
if (a == null) return new int[2];
return CAccessibility.invokeAndWait(new Callable<int[]>() {
public int[] call() {
final AccessibleContext ac = a.getAccessibleContext();
if (ac == null) return new int[2];
final AccessibleText at = ac.getAccessibleText();
if (at == null) return new int[2];
final int[] ret = new int[2];
ret[0] = at.getSelectionStart();
ret[1] = at.getSelectionEnd();
return ret;
}
}, c);
}
static int[] getSelectedTextRange(final Accessible a, final Component c) {
if (a == null) return new int[2];
return CAccessibility.invokeAndWait(new Callable<int[]>() {
public int[] call() {
final AccessibleContext ac = a.getAccessibleContext();
if (ac == null) return new int[2];
final AccessibleText at = ac.getAccessibleText();
if (at == null) return new int[2];
final int[] ret = new int[2];
ret[0] = at.getSelectionStart();
ret[1] = at.getSelectionEnd();
return ret;
}
}, c);
}
/**
* Invokes the <code>getAccessibleChild</code> method on each UI handled by this object.
*
* @return the value obtained from the first UI, which is
* the UI obtained from the default <code>LookAndFeel</code>
*/
public Accessible getAccessibleChild(JComponent a, int b) {
Accessible returnValue =
((ComponentUI) (uis.elementAt(0))).getAccessibleChild(a,b);
for (int i = 1; i < uis.size(); i++) {
((ComponentUI) (uis.elementAt(i))).getAccessibleChild(a,b);
}
return returnValue;
}
/**
* Invokes the <code>getAccessibleChild</code> method on each UI handled by this object.
*
* @return the value obtained from the first UI, which is
* the UI obtained from the default <code>LookAndFeel</code>
*/
public Accessible getAccessibleChild(JComponent a, int b) {
Accessible returnValue =
((ComponentUI) (uis.elementAt(0))).getAccessibleChild(a,b);
for (int i = 1; i < uis.size(); i++) {
((ComponentUI) (uis.elementAt(i))).getAccessibleChild(a,b);
}
return returnValue;
}
/**
* Invokes the <code>getAccessibleChild</code> method on each UI handled by this object.
*
* @return the value obtained from the first UI, which is
* the UI obtained from the default <code>LookAndFeel</code>
*/
public Accessible getAccessibleChild(JComponent a, int b) {
Accessible returnValue =
uis.elementAt(0).getAccessibleChild(a,b);
for (int i = 1; i < uis.size(); i++) {
uis.elementAt(i).getAccessibleChild(a,b);
}
return returnValue;
}
/**
* Invokes the <code>getAccessibleChild</code> method on each UI handled by this object.
*
* @return the value obtained from the first UI, which is
* the UI obtained from the default <code>LookAndFeel</code>
*/
public Accessible getAccessibleChild(JComponent a, int b) {
Accessible returnValue =
((ComponentUI) (uis.elementAt(0))).getAccessibleChild(a,b);
for (int i = 1; i < uis.size(); i++) {
((ComponentUI) (uis.elementAt(i))).getAccessibleChild(a,b);
}
return returnValue;
}
static String getSelectedText(final Accessible a, final Component c) {
if (a == null) return null;
return CAccessibility.invokeAndWait(new Callable<String>() {
public String call() throws Exception {
final AccessibleContext ac = a.getAccessibleContext();
if (ac == null) return null;
final AccessibleText at = ac.getAccessibleText();
if (at == null) return null;
return at.getSelectedText();
}
}, c);
}
/**
* Invokes the <code>getAccessibleChild</code> method on each UI handled by this object.
*
* @return the value obtained from the first UI, which is
* the UI obtained from the default <code>LookAndFeel</code>
*/
public Accessible getAccessibleChild(JComponent a, int b) {
Accessible returnValue =
((ComponentUI) (uis.elementAt(0))).getAccessibleChild(a,b);
for (int i = 1; i < uis.size(); i++) {
((ComponentUI) (uis.elementAt(i))).getAccessibleChild(a,b);
}
return returnValue;
}
/**
* Invokes the <code>getAccessibleChild</code> method on each UI handled by this object.
*
* @return the value obtained from the first UI, which is
* the UI obtained from the default <code>LookAndFeel</code>
*/
public Accessible getAccessibleChild(JComponent a, int b) {
Accessible returnValue =
((ComponentUI) (uis.elementAt(0))).getAccessibleChild(a,b);
for (int i = 1; i < uis.size(); i++) {
((ComponentUI) (uis.elementAt(i))).getAccessibleChild(a,b);
}
return returnValue;
}
/**
* Invokes the <code>getAccessibleChild</code> method on each UI handled by this object.
*
* @return the value obtained from the first UI, which is
* the UI obtained from the default <code>LookAndFeel</code>
*/
public Accessible getAccessibleChild(JComponent a, int b) {
Accessible returnValue =
((ComponentUI) (uis.elementAt(0))).getAccessibleChild(a,b);
for (int i = 1; i < uis.size(); i++) {
((ComponentUI) (uis.elementAt(i))).getAccessibleChild(a,b);
}
return returnValue;
}
/**
* Invokes the <code>getAccessibleChild</code> method on each UI handled by this object.
*
* @return the value obtained from the first UI, which is
* the UI obtained from the default <code>LookAndFeel</code>
*/
public Accessible getAccessibleChild(JComponent a, int b) {
Accessible returnValue =
((ComponentUI) (uis.elementAt(0))).getAccessibleChild(a,b);
for (int i = 1; i < uis.size(); i++) {
((ComponentUI) (uis.elementAt(i))).getAccessibleChild(a,b);
}
return returnValue;
}
private JPopupMenu getPopupMenu() {
for (int i = 0; i < getAccessibleContext().getAccessibleChildrenCount(); i++) {
Accessible child = getAccessibleContext().getAccessibleChild(i);
if (child instanceof JPopupMenu) {
return (JPopupMenu) child;
}
}
return null;
}
/**
* Invokes the <code>getAccessibleChild</code> method on each UI handled by this object.
*
* @return the value obtained from the first UI, which is
* the UI obtained from the default <code>LookAndFeel</code>
*/
public Accessible getAccessibleChild(JComponent a, int b) {
Accessible returnValue =
((ComponentUI) (uis.elementAt(0))).getAccessibleChild(a,b);
for (int i = 1; i < uis.size(); i++) {
((ComponentUI) (uis.elementAt(i))).getAccessibleChild(a,b);
}
return returnValue;
}
static int[] getVisibleCharacterRange(final Accessible a, final Component c) {
if (a == null) return null;
return CAccessibility.invokeAndWait(new Callable<int[]>() {
public int[] call() {
return getVisibleCharacterRange(a);
}
}, c);
}
/**
* Invokes the <code>getAccessibleChild</code> method on each UI handled by this object.
*
* @return the value obtained from the first UI, which is
* the UI obtained from the default <code>LookAndFeel</code>
*/
public Accessible getAccessibleChild(JComponent a, int b) {
Accessible returnValue =
((ComponentUI) (uis.elementAt(0))).getAccessibleChild(a,b);
for (int i = 1; i < uis.size(); i++) {
((ComponentUI) (uis.elementAt(i))).getAccessibleChild(a,b);
}
return returnValue;
}
/**
* Invokes the <code>getAccessibleChild</code> method on each UI handled by this object.
*
* @return the value obtained from the first UI, which is
* the UI obtained from the default <code>LookAndFeel</code>
*/
public Accessible getAccessibleChild(JComponent a, int b) {
Accessible returnValue =
((ComponentUI) (uis.elementAt(0))).getAccessibleChild(a,b);
for (int i = 1; i < uis.size(); i++) {
((ComponentUI) (uis.elementAt(i))).getAccessibleChild(a,b);
}
return returnValue;
}
static String getSelectedText(final Accessible a, final Component c) {
if (a == null) return null;
return CAccessibility.invokeAndWait(new Callable<String>() {
public String call() throws Exception {
final AccessibleContext ac = a.getAccessibleContext();
if (ac == null) return null;
final AccessibleText at = ac.getAccessibleText();
if (at == null) return null;
return at.getSelectedText();
}
}, c);
}
static int[] getRangeForLine(final Accessible a, final int lineIndex) {
Accessible sa = CAccessible.getSwingAccessible(a);
if (!(sa instanceof JTextComponent)) return null;
final JTextComponent jc = (JTextComponent) sa;
final Element root = jc.getDocument().getDefaultRootElement();
final Element line = root.getElement(lineIndex);
if (line == null) return null;
return new int[] { line.getStartOffset(), line.getEndOffset() };
}
/**
* Invokes the <code>getAccessibleChild</code> method on each UI handled by this object.
*
* @return the value obtained from the first UI, which is
* the UI obtained from the default <code>LookAndFeel</code>
*/
public Accessible getAccessibleChild(JComponent a, int b) {
Accessible returnValue =
((ComponentUI) (uis.elementAt(0))).getAccessibleChild(a,b);
for (int i = 1; i < uis.size(); i++) {
((ComponentUI) (uis.elementAt(i))).getAccessibleChild(a,b);
}
return returnValue;
}
/**
* Invokes the <code>getAccessibleChild</code> method on each UI handled by this object.
*
* @return the value obtained from the first UI, which is
* the UI obtained from the default <code>LookAndFeel</code>
*/
public Accessible getAccessibleChild(JComponent a, int b) {
Accessible returnValue =
((ComponentUI) (uis.elementAt(0))).getAccessibleChild(a,b);
for (int i = 1; i < uis.size(); i++) {
((ComponentUI) (uis.elementAt(i))).getAccessibleChild(a,b);
}
return returnValue;
}
/**
* Invokes the <code>getAccessibleChild</code> method on each UI handled by this object.
*
* @return the value obtained from the first UI, which is
* the UI obtained from the default <code>LookAndFeel</code>
*/
public Accessible getAccessibleChild(JComponent a, int b) {
Accessible returnValue =
((ComponentUI) (uis.elementAt(0))).getAccessibleChild(a,b);
for (int i = 1; i < uis.size(); i++) {
((ComponentUI) (uis.elementAt(i))).getAccessibleChild(a,b);
}
return returnValue;
}
private JPopupMenu getPopupMenu() {
for (int i = 0; i < getAccessibleContext().getAccessibleChildrenCount(); i++) {
Accessible child = getAccessibleContext().getAccessibleChild(i);
if (child instanceof JPopupMenu) {
return (JPopupMenu) child;
}
}
return null;
}
public Accessible getAccessibleSelection(int i) {
int index = getSelectedIndex();
if (index == -1) {
return null;
}
return pages.get(index);
}
/**
* Invokes the <code>getAccessibleChild</code> method on each UI handled by this object.
*
* @return the value obtained from the first UI, which is
* the UI obtained from the default <code>LookAndFeel</code>
*/
public Accessible getAccessibleChild(JComponent a, int b) {
Accessible returnValue =
((ComponentUI) (uis.elementAt(0))).getAccessibleChild(a,b);
for (int i = 1; i < uis.size(); i++) {
((ComponentUI) (uis.elementAt(i))).getAccessibleChild(a,b);
}
return returnValue;
}
/**
* Invokes the <code>getAccessibleChild</code> method on each UI handled by this object.
*
* @return the value obtained from the first UI, which is
* the UI obtained from the default <code>LookAndFeel</code>
*/
public Accessible getAccessibleChild(JComponent a, int b) {
Accessible returnValue =
((ComponentUI) (uis.elementAt(0))).getAccessibleChild(a,b);
for (int i = 1; i < uis.size(); i++) {
((ComponentUI) (uis.elementAt(i))).getAccessibleChild(a,b);
}
return returnValue;
}
/**
* Invokes the <code>getAccessibleChild</code> method on each UI handled by this object.
*
* @return the value obtained from the first UI, which is
* the UI obtained from the default <code>LookAndFeel</code>
*/
public Accessible getAccessibleChild(JComponent a, int b) {
Accessible returnValue =
((ComponentUI) (uis.elementAt(0))).getAccessibleChild(a,b);
for (int i = 1; i < uis.size(); i++) {
((ComponentUI) (uis.elementAt(i))).getAccessibleChild(a,b);
}
return returnValue;
}
/**
* Invokes the <code>getAccessibleChild</code> method on each UI handled by this object.
*
* @return the value obtained from the first UI, which is
* the UI obtained from the default <code>LookAndFeel</code>
*/
public Accessible getAccessibleChild(JComponent a, int b) {
Accessible returnValue =
((ComponentUI) (uis.elementAt(0))).getAccessibleChild(a,b);
for (int i = 1; i < uis.size(); i++) {
((ComponentUI) (uis.elementAt(i))).getAccessibleChild(a,b);
}
return returnValue;
}