< prev index next >

src/java.desktop/share/classes/javax/swing/plaf/basic/BasicMenuUI.java

Print this page




 106         if (changeListener != null)
 107             menuItem.addChangeListener(changeListener);
 108 
 109         if (menuListener == null)
 110             menuListener = createMenuListener(menuItem);
 111 
 112         if (menuListener != null)
 113             ((JMenu)menuItem).addMenuListener(menuListener);
 114     }
 115 
 116     protected void installKeyboardActions() {
 117         super.installKeyboardActions();
 118         updateMnemonicBinding();
 119     }
 120 
 121     void installLazyActionMap() {
 122         LazyActionMap.installLazyActionMap(menuItem, BasicMenuUI.class,
 123                                            getPropertyPrefix() + ".actionMap");
 124     }
 125 

 126     void updateMnemonicBinding() {
 127         int mnemonic = menuItem.getModel().getMnemonic();
 128         int[] shortcutKeys = (int[])DefaultLookup.get(menuItem, this,
 129                                                    "Menu.shortcutKeys");
 130         if (shortcutKeys == null) {
 131             shortcutKeys = new int[] {KeyEvent.ALT_MASK};
 132         }
 133         if (mnemonic == lastMnemonic) {
 134             return;
 135         }
 136         InputMap windowInputMap = SwingUtilities.getUIInputMap(
 137                        menuItem, JComponent.WHEN_IN_FOCUSED_WINDOW);
 138         if (lastMnemonic != 0 && windowInputMap != null) {
 139             for (int shortcutKey : shortcutKeys) {
 140                 windowInputMap.remove(KeyStroke.getKeyStroke
 141                         (lastMnemonic, shortcutKey, false));
 142             }
 143         }
 144         if (mnemonic != 0) {
 145             if (windowInputMap == null) {




 106         if (changeListener != null)
 107             menuItem.addChangeListener(changeListener);
 108 
 109         if (menuListener == null)
 110             menuListener = createMenuListener(menuItem);
 111 
 112         if (menuListener != null)
 113             ((JMenu)menuItem).addMenuListener(menuListener);
 114     }
 115 
 116     protected void installKeyboardActions() {
 117         super.installKeyboardActions();
 118         updateMnemonicBinding();
 119     }
 120 
 121     void installLazyActionMap() {
 122         LazyActionMap.installLazyActionMap(menuItem, BasicMenuUI.class,
 123                                            getPropertyPrefix() + ".actionMap");
 124     }
 125 
 126     @SuppressWarnings("deprecation")
 127     void updateMnemonicBinding() {
 128         int mnemonic = menuItem.getModel().getMnemonic();
 129         int[] shortcutKeys = (int[])DefaultLookup.get(menuItem, this,
 130                                                    "Menu.shortcutKeys");
 131         if (shortcutKeys == null) {
 132             shortcutKeys = new int[] {KeyEvent.ALT_MASK};
 133         }
 134         if (mnemonic == lastMnemonic) {
 135             return;
 136         }
 137         InputMap windowInputMap = SwingUtilities.getUIInputMap(
 138                        menuItem, JComponent.WHEN_IN_FOCUSED_WINDOW);
 139         if (lastMnemonic != 0 && windowInputMap != null) {
 140             for (int shortcutKey : shortcutKeys) {
 141                 windowInputMap.remove(KeyStroke.getKeyStroke
 142                         (lastMnemonic, shortcutKey, false));
 143             }
 144         }
 145         if (mnemonic != 0) {
 146             if (windowInputMap == null) {


< prev index next >