File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mnemonics in a JButton

 
Christopher C. Cook
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 196
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic