• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

setMnemonic() not working

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello..
I have written a small program..this is the example program shown in the official tutorials(uiswing) on oracle website..
i only made some minor changes..but somehow setMnemonic() is not working..
Can somebody please point out my mistake..
Here's My code..



Thank You.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My guess is that KeyEvent.VK_B represents "b" and you're expecting the setMnemonic method to make that apply to a different letter, namely "B".

Edit: No, that's wrong. The documentation says that setMnemonic is case-insensitive. So, what makes you think it isn't working?
 
Greenhorn
Posts: 29
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believe I've read before (I'll try and look it up to cite this) that with Jbuttons you set the mnemonic but you need to access it with the 'ALT' key.
So try 'ALT + B' etc. Let me know.

I cant find the documentation however...

JavaDocs

This is a little SSCCE example from the website which is a JButton with the Mnemonic 'A' set to it. Indeed, if you press 'A' nothing happens
however if you try 'Alt + A' then the button is pressed.
 
Vidur Koushik
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank You @@Keshan Pillay and @@Paul Clapham
I realized that we have to press "ALT+B".
and it that is the way it works.

Thanks once again for your replies.
reply
    Bookmark Topic Watch Topic
  • New Topic