You have two types of keyboard shortcuts: mnemonics and accelerators.
Mnemonics are usually triggered using Alt + KEY. This is a letter that is underlined in the text of a menu item (for example, F for a file). Accelerators are application shortcuts that are usually launched using Ctrl + KEY.
To use mnemonics, you can use the setMnemonic() method:
menuItem.setMnemonic('F');
To use accelerators, you must use the setAccelerator() method.
menuItem.setAccelerator(KeyStroke.getKeyStroke( java.awt.event.KeyEvent.VK_S, java.awt.Event.CTRL_MASK));
Vivien barousse
source share