aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Mnemonic question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Mnemonic question" Watch "Mnemonic question" New topic
Author

Mnemonic question

Meyer Florian
Ranch Hand

Joined: Oct 20, 2003
Posts: 62
Hey there!
I have a JButton and called setMnemonic(KeyEvent.VK_ENTER); on it. But the button won't be invoked when I press the enter-key. When I set the mnemonic shortcut to 'b' or something else, it doesn't work either. The JButton is inside of a JPanel which is inside of a JDialog.
Thanks for help
Florian Meyer
Daniel Puryear
Greenhorn

Joined: Jun 02, 2002
Posts: 22
What Listener interfaces have you implemented? If you want to work at the VK_ENTER level, use the KeyListener. If you want to work at the symantic level, use the ActionListener...
Brian Knight
Greenhorn

Joined: Jun 02, 2003
Posts: 16
Does the text on your button actually have a 'b' in it? Setting the mnemonic to enter won't work, as you should rather register a keyboard action if this is the key you wish to use, or look at setDefaultCapable() on JButton (Key stroke would then depend on your current look and feel). If you wish to use mnemonics the char you set as the mnemonic should be contained in the text of you button for it to work properly (and for it to make sense to the user).
 
jQuery in Action, 2nd edition
 
subject: Mnemonic question