This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Tabbing between cells in a JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Tabbing between cells in a JTable" Watch "Tabbing between cells in a JTable" New topic
Author

Tabbing between cells in a JTable

Jonathan Moore
Ranch Hand

Joined: Nov 02, 2005
Posts: 36
I'm trying to create a JTable that acts like a set of JTextFields, with the top row and left column rendered as JLabels. The code below works fine, but I'd like to be able to tab between cells and the cell to immediately go into edit mode (so it's invisible to the user that this is actually a table). Additionally I'd like it to skip uneditable cells, so tabbing on a far right cell doesn't move to the label on the next row, but to the next editable cell. I've spent quite a while trying to figure this one out but with no luck, so does anyone have any pointers?

If you run the code below you will see that clicking in an editable cell automatically puts it into edit mode (with cursor and changed text position) but tabbing doesn't give any visual indications, though if you start typing it starts editing.

Thanks for any help, and here;s the code:

Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
I'd like to be able to tab between cells and the cell to immediately go into edit mode
(so it's invisible to the user that this is actually a table). Additionally I'd like it to
skip uneditable cells, so tabbing on a far right cell doesn't move to the label on the
next row, but to the next editable cell.

I got your code to work (as described above) with only the following additions:
Jonathan Moore
Ranch Hand

Joined: Nov 02, 2005
Posts: 36
That's great - thanks for your help Craig.

Jon
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tabbing between cells in a JTable
 
Similar Threads
JTable
Tabbing between editable cells in JTable
JTable Custon Renderes
TextField in JTable
JTable CellEditor formatting.