0

We often see in applications, a menu at the top (File, Edit, View...) composed of JMenuItems that can be reached by clicking on them or by typing the underlined rule of this JMenuItem.

I can't reproduce this last behavior whether I put my KeyListner on the JMenuBar or the JMenu. How to listen to the keyboard after clicking on a JMenu?

mnNewMenu_1.addKeyListener(new KeyAdapter() {
            @Override
            public void keyReleased(KeyEvent e) {
                if(e.getKeyCode() == KeyEvent.VK_O)
                {
                    mnNewMenu_7.setArmed(true);
                }
            }
        });
idIA Tech
  • 23
  • 3
  • https://stackoverflow.com/questions/13366793/how-do-you-make-menu-item-jmenuitem-shortcut – PeterMmm Feb 18 '23 at 16:22
  • Read the section from the Swing tutorial on [How to Use Menus](https://docs.oracle.com/javase/tutorial/uiswing/components/menu.html) for examples of using `mnemonics` and `accelerators`. The tutorial contains examples of most Swing basics for all components. – camickr Feb 18 '23 at 17:34

0 Answers0