• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Mnemonics in a JButton

 
Greenhorn
Posts: 1
  • 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
 
Ranch Hand
Posts: 196
  • 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
 
Stinging nettles are edible. But I really want to see you try to eat this tiny ad:
create, convert, edit or print DOC and DOCX in Java
https://products.aspose.com/words/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!