• 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:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Mnemonic question  RSS feed

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!