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


Java AccessibleContext.getAccessibleRole方法代碼示例

本文整理匯總了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");
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:11,代碼來源:bug6986385.java

示例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);
                    }
                }
            }
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:48,代碼來源:CAccessible.java


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