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

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: 28296
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.
 
Because those who mind don't matter and those who matter don't mind - Seuss. Tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic