wood burning stoves*
The moose likes Swing / AWT / SWT and the fly likes Mnemonics in a JButton Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Mnemonics in a JButton" Watch "Mnemonics in a JButton" New topic
Author

Mnemonics in a JButton

Christopher C. Cook
Greenhorn

Joined: Jul 08, 2002
Posts: 1
Hi all,
I was wondering if anyone could tell me how to make a mnemonic work without using Alt in a metal-feel application. I am building an app in which the users want to hit PF9 to activate a button on the GUI. Any ideas how to set this mnemonic?
Thanks a lot.
Chris
Rene Liebmann
Ranch Hand

Joined: May 02, 2002
Posts: 196
Hi Christopher,
welcome to JavaRanch. Your requested feature doesn't work with a Mnemonic, because a mnemonic consists of the ALT button and a letter, which is part of the buttons text, but there are lots of workarounds possible.
One thing, which I like is a non visible JMenuItem. This can have your requested button as an Accelerator.
Another possibility is, that your main application (JFrame) listens for all key events and if PF9 is pressed, then you can do your action.
But it will not work if your JButton will listen for PF9.
Hope that helps
Rene
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Mnemonics in a JButton
 
Similar Threads
swing mnemonic Problem not display at windows
Underline first character of a JButton?
Help me! GUI gurus.
what is the value of 8 | 9 & 10 ^ 11 ?
How to set mnemonic for open and close buttons of a JFileChooser