當前位置: 首頁>>代碼示例>>Java>>正文


Java Accessible類代碼示例

本文整理匯總了Java中javax.accessibility.Accessible的典型用法代碼示例。如果您正苦於以下問題:Java Accessible類的具體用法?Java Accessible怎麽用?Java Accessible使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Accessible類屬於javax.accessibility包,在下文中一共展示了Accessible類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getVisibleCharacterRange

import javax.accessibility.Accessible; //導入依賴的package包/類
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 };
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:18,代碼來源:CAccessibleText.java

示例2: setSelectedTextRange

import javax.accessibility.Accessible; //導入依賴的package包/類
static void setSelectedTextRange(final Accessible a, final Component c, final int startIndex, final int endIndex) {
    if (a == null) return;

    CAccessibility.invokeLater(new Runnable() {
        public void run() {
            final AccessibleContext ac = a.getAccessibleContext();
            if (ac == null) return;

            final AccessibleEditableText aet = ac.getAccessibleEditableText();
            if (aet == null) return;

            final boolean validRange = (startIndex >= 0) && (endIndex >= startIndex) && (endIndex <= aet.getCharCount());
            if (!validRange) return;

            aet.selectText(startIndex, endIndex);
        }
    }, c);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:19,代碼來源:CAccessibleText.java

示例3: updateAccessible

import javax.accessibility.Accessible; //導入依賴的package包/類
private void updateAccessible() {
    AccessibleContext editorAC = editorComponent.getAccessibleContext();
    if (accessibleFakeLabel == null) {
        accessibleFakeLabel = new JLabel(""); //NOI18N
        editorAC.firePropertyChange(AccessibleContext.ACCESSIBLE_CHILD_PROPERTY, null, accessibleFakeLabel);
    }
    JLabel orig = accessibleLabel;
    editorAC.firePropertyChange(AccessibleContext.ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY, accessibleLabel, accessibleFakeLabel);
    Object selectedValue = getSelectedValue();
    String accName = null;
    if (selectedValue instanceof Accessible) {
        AccessibleContext ac = ((Accessible) selectedValue).getAccessibleContext();
        if (ac != null) {
            accName = ac.getAccessibleName();
        }
    }
    if (accName == null && selectedValue != null) {
        accName = selectedValue.toString();
    }
    if (accName != null) {
        accessibleLabel = new JLabel(LocaleSupport.getString("ACSN_CompletionView_SelectedItem") + accName); //NOI18N
        editorAC.firePropertyChange(AccessibleContext.ACCESSIBLE_CHILD_PROPERTY, null, accessibleLabel);
        editorAC.firePropertyChange(AccessibleContext.ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY, accessibleFakeLabel, accessibleLabel);
        if (orig != null) {
            editorAC.firePropertyChange(AccessibleContext.ACCESSIBLE_CHILD_PROPERTY, orig, null);
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:29,代碼來源:CompletionJList.java

示例4: getCharacterIndexAtPosition

import javax.accessibility.Accessible; //導入依賴的package包/類
static int getCharacterIndexAtPosition(final Accessible a, final Component c, final int x, final int y) {
    if (a == null) return 0;

    return CAccessibility.invokeAndWait(new Callable<Integer>() {
        public Integer call() throws Exception {
            final AccessibleContext ac = a.getAccessibleContext();
            if (ac == null) return null;
            final AccessibleText at = ac.getAccessibleText();
            if (at == null) return null;
            // (x, y) passed in as java screen coords - (0, 0) at upper-left corner of screen.
            // Convert to java component-local coords
            final Point componentLocation = ac.getAccessibleComponent().getLocationOnScreen();
            final int localX = x - (int)componentLocation.getX();
            final int localY = y - (int)componentLocation.getY();

            return at.getIndexAtPoint(new Point(localX, localY));
        }
    }, c);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:20,代碼來源:CAccessibleText.java

示例5: getAccessibleChild

import javax.accessibility.Accessible; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:15,代碼來源:MultiTabbedPaneUI.java

示例6: getAccessibleChild

import javax.accessibility.Accessible; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:15,代碼來源:MultiOptionPaneUI.java

示例7: setSelectedText

import javax.accessibility.Accessible; //導入依賴的package包/類
static void setSelectedText(final Accessible a, final Component c, final String newText) {
    if (a == null) return;

    CAccessibility.invokeLater(new Runnable() {
        public void run() {
            final AccessibleContext ac = a.getAccessibleContext();
            if (ac == null) return;

            final AccessibleEditableText aet = ac.getAccessibleEditableText();
            if (aet == null) return;

            final int selectionStart = aet.getSelectionStart();
            final int selectionEnd = aet.getSelectionEnd();
            aet.replaceText(selectionStart, selectionEnd, newText);
        }
    }, c);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:18,代碼來源:CAccessibleText.java

示例8: getSelectedTextRange

import javax.accessibility.Accessible; //導入依賴的package包/類
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);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:19,代碼來源:CAccessibleText.java

示例9: test

import javax.accessibility.Accessible; //導入依賴的package包/類
private static void test() {

        int N = 5;
        JTabbedPane tabbedPane = new JTabbedPane();

        for (int i = 0; i < N; i++) {
            tabbedPane.addTab("Title: " + i, new JLabel("Component: " + i));
        }

        for (int i = 0; i < tabbedPane.getTabCount(); i++) {
            Component child = tabbedPane.getComponentAt(i);

            AccessibleContext ac = child.getAccessibleContext();
            if (ac == null) {
                throw new RuntimeException("Accessible Context is null!");
            }

            int index = ac.getAccessibleIndexInParent();
            Accessible parent = ac.getAccessibleParent();

            if (parent.getAccessibleContext().getAccessibleChild(index) != child) {
                throw new RuntimeException("Wrong getAccessibleIndexInParent!");
            }
        }
    }
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:26,代碼來源:AccessibleIndexInParentTest.java

示例10: getPopupList

import javax.accessibility.Accessible; //導入依賴的package包/類
private static JList getPopupList( JComboBox combo ) {
    Accessible a = combo.getUI().getAccessibleChild(combo, 0);

    if( a instanceof ComboPopup ) {
        return ((ComboPopup) a).getList();
    }
    return null;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:9,代碼來源:ComboBoxAutoCompleteSupport.java

示例11: getAccessibleChild

import javax.accessibility.Accessible; //導入依賴的package包/類
/**
 * Return the specified Accessible child of the object.
 *
 * @param i zero-based index of child
 * @return the Accessible child of the object
 * @exception IllegalArgumentException if index is out of bounds
 */
@Override
public Accessible getAccessibleChild(int i) {
    if (i < 0 || i >= getModel().size()) {
        return null;
    }
    TabData data = getModel().getTab(i);
    if (data.getComponent() instanceof Accessible) {
        return (Accessible)data.getComponent();
    }
    return null;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:TabDisplayer.java

示例12: getAccessibleAt

import javax.accessibility.Accessible; //導入依賴的package包/類
/**
 * Returns the <code>Accessible</code> child contained at
 * the local coordinate <code>Point</code>, if one exists.
 * Otherwise returns the currently selected tab.
 *
 * @return the <code>Accessible</code> at the specified
 *    location, if it exists
 */
@Override
public Accessible getAccessibleAt(Point p) {
    int tab = tabForCoordinate(p);
    if (tab == -1) {
        tab = getSelectionModel().getSelectedIndex();
    }
    return getAccessibleChild(tab);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:TabDisplayer.java

示例13: getAccessibleChild

import javax.accessibility.Accessible; //導入依賴的package包/類
@Override
public Accessible getAccessibleChild(int i) {

    int childrenCount = super.getAccessibleChildrenCount();
    if( i < childrenCount ) {
        return super.getAccessibleChild( i );
    }
    if( i-childrenCount >= dividers.size() ) {
        return null;
    }
    
    MultiSplitDivider divider = dividers.get( i-childrenCount );
    return divider;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:15,代碼來源:MultiSplitPane.java

示例14: setAccessibleName

import javax.accessibility.Accessible; //導入依賴的package包/類
@Override
public void setAccessibleName(String name) {
    super.setAccessibleName(name);

    if (browserComponent instanceof Accessible) {
        browserComponent.getAccessibleContext().setAccessibleName(name);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:9,代碼來源:HtmlBrowser.java

示例15: setAccessibleDescription

import javax.accessibility.Accessible; //導入依賴的package包/類
@Override
public void setAccessibleDescription(String desc) {
    super.setAccessibleDescription(desc);

    if (browserComponent instanceof Accessible) {
        browserComponent.getAccessibleContext().setAccessibleDescription(desc);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:9,代碼來源:HtmlBrowser.java


注:本文中的javax.accessibility.Accessible類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。