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

java swing jbutton shortcut key

Sri Vijay
Greenhorn

Joined: Aug 31, 2010
Posts: 1
KeyboardFocusManager.getCurrentKeyboardFocusManager()
.addKeyEventDispatcher(new KeyEventDispatcher() {
public boolean dispatchKeyEvent(KeyEvent e) {
int c=e.getKeyCode();
if(c==KeyEvent.VK_F2)
{
joptionpane.showmessageDailogue(null,"Clicked");
}
};


This command is working, but if i press the f2 key the message box is coming even already a message box is already available,it shows a message box on the top of the old message box,so if i press two times f2 key two message box are coming is ther any solution for this



thank you

regards
SriVijay
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19653
    
  18

Use a key binding instead. This way, the modal dialog will block access to the frame and therefore also its key bindings. Check out the Sun/Oracle tutorial for more info.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java swing jbutton shortcut key
 
Similar Threads
trying eclipse/wsad - I miss IntelliJ
Keys for JButtons
Mock Exam Question Doubt, 61:69 from K&B CD
"Show Tooltip Description", "Press 'F2' for focus." in Eclipse
Handling External Event