本文整理匯總了Java中javax.accessibility.AccessibleContext.getAccessibleRole方法的典型用法代碼示例。如果您正苦於以下問題:Java AccessibleContext.getAccessibleRole方法的具體用法?Java AccessibleContext.getAccessibleRole怎麽用?Java AccessibleContext.getAccessibleRole使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.accessibility.AccessibleContext
的用法示例。
在下文中一共展示了AccessibleContext.getAccessibleRole方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import javax.accessibility.AccessibleContext; //導入方法依賴的package包/類
public static void main(String... args) throws Exception {
JLayer l = new JLayer();
AccessibleContext acc = l.getAccessibleContext();
if (acc == null) {
throw new RuntimeException("JLayer's AccessibleContext is null");
}
if (acc.getAccessibleRole() != AccessibleRole.PANEL) {
throw new RuntimeException("JLayer's AccessibleRole must be PANEL");
}
}
示例2: propertyChange
import javax.accessibility.AccessibleContext; //導入方法依賴的package包/類
@Override
public void propertyChange(PropertyChangeEvent e) {
String name = e.getPropertyName();
if ( ptr != 0 ) {
Object newValue = e.getNewValue();
Object oldValue = e.getOldValue();
if (name.compareTo(ACCESSIBLE_CARET_PROPERTY) == 0) {
selectedTextChanged(ptr);
} else if (name.compareTo(ACCESSIBLE_TEXT_PROPERTY) == 0 ) {
valueChanged(ptr);
} else if (name.compareTo(ACCESSIBLE_SELECTION_PROPERTY) == 0 ) {
selectionChanged(ptr);
} else if (name.compareTo(ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY) == 0 ) {
if (newValue instanceof AccessibleContext) {
activeDescendant = (AccessibleContext)newValue;
}
} else if (name.compareTo(ACCESSIBLE_STATE_PROPERTY) == 0) {
AccessibleContext thisAC = accessible.getAccessibleContext();
AccessibleRole thisRole = thisAC.getAccessibleRole();
Accessible parentAccessible = thisAC.getAccessibleParent();
AccessibleRole parentRole = null;
if (parentAccessible != null) {
parentRole = parentAccessible.getAccessibleContext().getAccessibleRole();
}
// At least for now don't handle combo box menu state changes.
// This may change when later fixing issues which currently
// exist for combo boxes, but for now the following is only
// for JPopupMenus, not for combobox menus.
if (parentRole != AccessibleRole.COMBO_BOX) {
if (thisRole == AccessibleRole.POPUP_MENU) {
if ( newValue != null &&
((AccessibleState)newValue) == AccessibleState.VISIBLE ) {
menuOpened(ptr);
} else if ( oldValue != null &&
((AccessibleState)oldValue) == AccessibleState.VISIBLE ) {
menuClosed(ptr);
}
} else if (thisRole == AccessibleRole.MENU_ITEM) {
if ( newValue != null &&
((AccessibleState)newValue) == AccessibleState.FOCUSED ) {
menuItemSelected(ptr);
}
}
}
}
}
}