This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTable - Enter instead of Tab

 
Victoria Bernstein
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic