Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to create key stroke listen?

 
reubin haz
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know how to do event listener with mouse. But I have difficulty to create key stroke listener.
I have a swing table, that when multiple rows are selected. I wanna disable a button. But users can still select multiple rows by using shift+up or shift+down.
How is the event for this kind of key stroke to be create?

Thanks.
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why would you need a keystroke listener for that?

If you want something to happen to your GUI when a certain selection event takes place, then just use a selection listener. Don't waste your time writing picky-picky code which looks for mouse clicks and tries to figure out what row was clicked on and then what that meant in terms of rows selected. The component does all of that for you already.
 
reubin haz
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for your point, that way is much better.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic