Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Bind jbutton event to a keystroke

 
Kasun Wixkramanayake
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Sheriff
Pie
Posts: 20774
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5125
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic