< prev index next >

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

Print this page

     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) {
     147                 windowInputMap = createInputMap(JComponent.
     148                                               WHEN_IN_FOCUSED_WINDOW);
     149                 SwingUtilities.replaceUIInputMap(menuItem, JComponent.
     150                                        WHEN_IN_FOCUSED_WINDOW, windowInputMap);
     151             }
     152             for (int shortcutKey : shortcutKeys) {
     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                     KeyEvent.ALT_MASK | KeyEvent.ALT_GRAPH_MASK};
     134         }
     135         if (mnemonic == lastMnemonic) {
     136             return;
     137         }
     138         InputMap windowInputMap = SwingUtilities.getUIInputMap(
     139                        menuItem, JComponent.WHEN_IN_FOCUSED_WINDOW);
     140         if (lastMnemonic != 0 && windowInputMap != null) {
     141             for (int shortcutKey : shortcutKeys) {
     142                 windowInputMap.remove(KeyStroke.getKeyStroke
     143                         (lastMnemonic, shortcutKey, false));
     144             }
     145         }
     146         if (mnemonic != 0) {
     147             if (windowInputMap == null) {
     148                 windowInputMap = createInputMap(JComponent.
     149                                               WHEN_IN_FOCUSED_WINDOW);
     150                 SwingUtilities.replaceUIInputMap(menuItem, JComponent.
     151                                        WHEN_IN_FOCUSED_WINDOW, windowInputMap);
     152             }
     153             for (int shortcutKey : shortcutKeys) {

< prev index next >