KeyListener on JMenuBar

21 Views Asked by At

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);
                }
            }
        });
0

There are 0 best solutions below