Make F1 short cut key in Swing

java, keyboard-shortcuts, swing

Solution

Using `Action`, as shown here and here, can make these settings easier to manage. Also consider `getMenuShortcutKeyMask()` instead of assuming `Event.CTRL_MASK`.

Problem

I have a Java Swing app in Which I have been able to set shortcut keys using the following piece of code. For example Ctrl+K. ``` keyHelp.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_K, Event.CTRL_MASK)); keyHelp.setMnemonic((int) 'K');//This is the Line I need Help in ``` I just can't figure out how to add the same using F1 key as the shortcut... Could anyone please help?

Original source

Related problems