Click to See Complete Forum and Search --> : Set F1 as the shortcut to a help menu


oontvoo
May 10th, 2010, 10:42 PM
Hi,
I was making a menu bar for my JFrame, which contains a menu item named "Help".

I'm wondering how to make F1 a shortcut to that menu item. I thought of using .setAccelorator()., but that didn't seem to work.
So can you show me how?

Thanks!

dlorde
May 11th, 2010, 03:44 AM
I'm wondering how to make F1 a shortcut to that menu item. I thought of using .setAccelorator()., but that didn't seem to work.

Setting an accelerator on the action should work - that's what they're for. Show us the code you tried that doesn't work.

You could set a mnemonic (see Menu - Enabling Keyboard Operation (http://java.sun.com/docs/books/tutorial/uiswing/components/menu.html#mnemonic)), but that's not quite the same thing.

Being abstract is something profoundly different from being vague... The purpose of abstraction is not to be vague, but to create a new semantic level in which one can be absolutely precise...
E. Dijkstra