This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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

Set colon mnemonic key for JLabel  RSS feed

 
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello sir, madam, friends,

I have a JLabel associated with a textfield.
I want to set VK_COLON mnemonic key for JLabel. However just by calling the method setMnemonic(KeyEvent.VK_COLON); and setLabelFor(myTextField) isnt helping me to get focus in textfield. I guess this involves the use of ALT and SHIFT key combination. So is there any way to set colon mnemonic key ?

Please help.

Waiting for your replies.

Thanks and Regards
Rohit.
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Press the shift and semicolon keys together.
 
Rohit Bhagwat
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply. I actually tried running your program but I was unable to set the focus in textfield by pressing ALT + SHIFT + COLON.

Thanks and Regards
Rohit
 
Marshal
Posts: 60101
188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried it and it works. Leave out the ALT key.
 
Rohit Bhagwat
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
KeyStroke keyStroke = KeyStroke.getKeyStroke("alt shift SEMICOLON");

I added the "alt" word in the above statement and now it is working with ALT + SHIFT + COLON. However I noticed that the actionPerformed method is getting called but the focus is not getting set in the textfield. When I explicitly wrote textField.requestFocus(); in actionPerformed then the textfield got the focus else it is not receiving focus.

Please correct me if I am wrong.

Thanks and Regards
Rohit.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!