File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

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 i use above code to do that.but it didnt work(I use netbeans 6.9 ).please help me
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

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

Joined: May 03, 2008
Posts: 5115

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:
subject: Bind jbutton event to a keystroke
It's not a secret anymore!