当前位置: 首页>>代码示例>>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;未经允许,请勿转载。