aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Enter key and JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Enter key and JTable" Watch "Enter key and JTable" New topic
Author

Enter key and JTable

Rahul Mahindrakar
Ranch Hand

Joined: Jul 28, 2000
Posts: 1850
Hi ,
I want to capture the Enter key pressed for the JTable. Any ideas as to how to do it. By default pressing the Enter key will move the row selection down. I would like to change this. How is the question.

[This message has been edited by Rahul Mahindrakar (edited February 09, 2001).]
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
If you put a listener for a KeyEvent looking for VK_ENTER you can insert some control code when the key in pressed.


"JavaRanch, where the deer and the Certified play" - David O'Meara
Joachim Olga
Greenhorn

Joined: May 15, 2004
Posts: 9
Using a key listener doesn't react to the first press on the enter key, only the second.
nikos sokaf
Ranch Hand

Joined: May 01, 2004
Posts: 57
It reacts on the first KEY stroke by using the following method:

table.setSurrendersFocusOnKeystroke(true);
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Enter key and JTable