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 Enter key and JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Enter key and JTable" Watch "Enter key and JTable" New topic

Enter key and JTable

Rahul Mahindrakar
Ranch Hand

Joined: Jul 28, 2000
Posts: 1868
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"

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

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:

I agree. Here's the link:
subject: Enter key and JTable
It's not a secret anymore!