wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes setMnemonic() not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "setMnemonic() not working" Watch "setMnemonic() not working" New topic
Author

setMnemonic() not working

narendra vuppuluri
Greenhorn

Joined: May 07, 2012
Posts: 9
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
Bartender

Joined: Oct 14, 2005
Posts: 18672
    
    8

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

Joined: May 21, 2008
Posts: 29
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.
narendra vuppuluri
Greenhorn

Joined: May 07, 2012
Posts: 9
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: setMnemonic() not working