• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

setMnemonic() not working

 
Vidur Koushik
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • 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.
 
Paul Clapham
Sheriff
Posts: 20984
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • 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?
 
Keshan Pillay
Greenhorn
Posts: 29
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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: 17
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic