javax.accessibility.Accessible Java Examples

The following examples show how to use javax.accessibility.Accessible. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CAccessibleText.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #2
Source File: CAccessibleText.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
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 };
}
 
Example #3
Source File: CAccessibleText.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #4
Source File: CAccessibleText.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #5
Source File: CAccessibleText.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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 };
}
 
Example #6
Source File: CAccessibleText.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static AccessibleEditableText getAccessibleEditableText(final Accessible a, final Component c) {
    if (a == null) return null;

    return CAccessibility.invokeAndWait(new Callable<AccessibleEditableText>() {
        public AccessibleEditableText call() throws Exception {
            final AccessibleContext ac = a.getAccessibleContext();
            if (ac == null) return null;
            return ac.getAccessibleEditableText();
        }
    }, c);
}
 
Example #7
Source File: MultiSplitPaneUI.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #8
Source File: MultiOptionPaneUI.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #9
Source File: MultiRootPaneUI.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #10
Source File: MultiScrollBarUI.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #11
Source File: MultiProgressBarUI.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #12
Source File: MultiTreeUI.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #13
Source File: MultiDesktopIconUI.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #14
Source File: CAccessible.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private CAccessible(final Accessible accessible) {
    super(0L, true); // real pointer will be poked in by native

    if (accessible == null) throw new NullPointerException();
    this.accessible = accessible;

    if (accessible instanceof Component) {
        addNotificationListeners((Component)accessible);
    }
}
 
Example #15
Source File: MultiMenuItemUI.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #16
Source File: MultiOptionPaneUI.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #17
Source File: CAccessibleText.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static String getStringForRange(final Accessible a, final Component c, final int location, final int length) {
    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 AccessibleEditableText aet = ac.getAccessibleEditableText();
            if (aet == null) return null;

            return aet.getTextRange(location, location + length);
        }
    }, c);
}
 
Example #18
Source File: MultiSplitPaneUI.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #19
Source File: MultiPanelUI.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #20
Source File: MultiTabbedPaneUI.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #21
Source File: CAccessibleText.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
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() };
}
 
Example #22
Source File: MultiOptionPaneUI.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #23
Source File: CAccessibleText.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example #24
Source File: MultiToolTipUI.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #25
Source File: MultiTableUI.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #26
Source File: MultiSeparatorUI.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #27
Source File: CAccessibleText.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example #28
Source File: MainPanel.java    From java-swing-tips with MIT License 5 votes vote down vote up
@Override protected void updateItem(int index) {
  if (isPopupVisible()) {
    CheckableItem item = getItemAt(index);
    item.setSelected(!item.isSelected());
    repaint();
    Accessible a = getAccessibleContext().getAccessibleChild(0);
    if (a instanceof ComboPopup) {
      ((ComboPopup) a).getList().repaint();
    }
  }
}
 
Example #29
Source File: MultiViewportUI.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #30
Source File: MultiOptionPaneUI.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}