本文整理汇总了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;
}
示例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!");
}
}
}
示例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;
}