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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTable - Enter instead of Tab" Watch "JTable - Enter instead of Tab" New topic
Author

JTable - Enter instead of Tab

Victoria Bernstein
Greenhorn

Joined: Dec 07, 2000
Posts: 15
Hi All,
I need to go to the next cell in the same row when Enter is pressed (same as Tab). I coded around it, but the problem is that the next row still gets selected for a fraction of a second, and only then the current row gets selected again. This happens because the default behavior of Enter is to go to the next row. How can I override that, make Enter work exactly as Tab?
Thank you very much,
Victoria
Buckley Lee
Greenhorn

Joined: Mar 28, 2001
Posts: 19
Try adding a KeyListener event to the table. When the event sees an enter key, goto the position in the table that you desire.
Do a search for KeyListener in the Java online documentation for reference on using it.
By the way, I've used KeyListeners before but haven't tried using one with a table. It will probably work though. Worth a try!!
Victoria Bernstein
Greenhorn

Joined: Dec 07, 2000
Posts: 15
Thanks, but that is exactly what I already tried. It works, but there is one big problem: for a fraction of a second (quite noticeable) next row gets selected and then the selection goes to where I programmed it. I added my functionality, but the old Tab functionality is still there.
Any other suggestions?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTable - Enter instead of Tab