Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Mnemonics in a JButton

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic