当前位置: 首页>>代码示例>>Java>>正文


Java Component.getAccessibleContext方法代码示例

本文整理汇总了Java中java.awt.Component.getAccessibleContext方法的典型用法代码示例。如果您正苦于以下问题:Java Component.getAccessibleContext方法的具体用法?Java Component.getAccessibleContext怎么用?Java Component.getAccessibleContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.Component的用法示例。


在下文中一共展示了Component.getAccessibleContext方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAccessibleChild

import java.awt.Component; //导入方法依赖的package包/类
/**
 * Returns the nth Accessible child of the object.
 *
 * @param i zero-based index of child
 * @return the nth Accessible child of the object
 */
public Accessible getAccessibleChild(int i) {
    Component[] children = getMenuComponents();
    int count = 0;
    for (Component child : children) {
        if (child instanceof Accessible) {
            if (count == i) {
                if (child instanceof JComponent) {
                    // FIXME:  [[[WDW - probably should set this when
                    // the component is added to the menu.  I tried
                    // to do this in most cases, but the separators
                    // added by addSeparator are hard to get to.]]]
                    AccessibleContext ac = child.getAccessibleContext();
                    ac.setAccessibleParent(JMenu.this);
                }
                return (Accessible) child;
            } else {
                count++;
            }
        }
    }
    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:29,代码来源:JMenu.java

示例2: test

import java.awt.Component; //导入方法依赖的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

示例3: getPanelAccessibleContext

import java.awt.Component; //导入方法依赖的package包/类
private AccessibleContext getPanelAccessibleContext() {
    if (myBar != null) {
        Component c = myBar.getParent();
        if (c instanceof Accessible) {
            return c.getAccessibleContext();
        }
    }
    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:ProgressMonitor.java


注:本文中的java.awt.Component.getAccessibleContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。