This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes how to create key stroke listen? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "how to create key stroke listen?" Watch "how to create key stroke listen?" New topic
Author

how to create key stroke listen?

reubin haz
Ranch Hand

Joined: May 12, 2005
Posts: 287
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.


SCJA, SCJP5.0, SCBCD, SCWCD
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

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

Joined: May 12, 2005
Posts: 287
thanks for your point, that way is much better.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how to create key stroke listen?
 
Similar Threads
how to be notified about selected row change? i mean user selected other row of jtabl
Passing key strokes between objects
Problem in Shift button keyPressed event
Passing key strokes between objects
How to create hot key?