wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Set colon mnemonic key for JLabel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Set colon mnemonic key for JLabel" Watch "Set colon mnemonic key for JLabel" New topic
Author

Set colon mnemonic key for JLabel

Rohit Bhagwat
Ranch Hand

Joined: Dec 19, 2004
Posts: 205
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.
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
Press the shift and semicolon keys together.
Rohit Bhagwat
Ranch Hand

Joined: Dec 19, 2004
Posts: 205
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
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36497
    
  16
I tried it and it works. Leave out the ALT key.
Rohit Bhagwat
Ranch Hand

Joined: Dec 19, 2004
Posts: 205
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Set colon mnemonic key for JLabel
 
Similar Threads
GUI question about tabbedPane
JTabbedPane Problem
set F11 key as mnemonic for jButton
JMenu
Help me! GUI gurus.