File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of Spring in Action this week in the Spring forum!
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: 19720
    
  20

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