I am creating a simple text editor similiar to Notepad.
It would insert the time and date to the file if the user presses F5.
I browsed about mnemonics and accelerators but they are used in combination with Alt and Ctrl respectively.
Should I use an EventListener or is there any other solution?
You could simply use:
with KeyStroke having
0specifying no modifiers as described in the docs.An ActionListener is the appropriate listener for menu item events.