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 Bind jbutton event to a  keystroke Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Bind jbutton event to a  keystroke" Watch "Bind jbutton event to a  keystroke" New topic
Author

Bind jbutton event to a keystroke

Kasun Wixkramanayake
Ranch Hand

Joined: Feb 09, 2010
Posts: 74


i need to bind a jbutton event to a keystroke.so i use above code to do that.but it didnt work(I use netbeans 6.9 ).please help me
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

I would say you would be better off creating an Action, and then binding both the JButton and the keystroke to that Action.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

Sorry, but that code is pretty meaningless. Lines 3 and 5 perform an identical assignment, and line 7 sets the same ActionMap that has just been retrieved. Whayt would you expect that to accomplish?

Recommended reading: How to Use Key Bindings


luck, db
There are no new questions, but there may be new answers.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Bind jbutton event to a keystroke
 
Similar Threads
getting KeyPressed for JDialog? example?
NX: How to register a key event to a frame
Using ActionMap for HotKey mapping
doing same job on two or more events
About Keybinding