This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Swing / AWT / SWT and the fly likes JTable Tabbing 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 "JTable Tabbing" Watch "JTable Tabbing" New topic
Author

JTable Tabbing

G Estes
Ranch Hand

Joined: Oct 22, 2002
Posts: 62
What would you suggest as the best approach to making the Shift+Tab move backward through the editable fields in a JTable (as is the behavior in MS Excel)? This would also mimic the the behavior on a panel with tab order set among text fields and buttons...the Shift+Tab will move backward through the order.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> What would you suggest as the best approach...

best? doubtful, but seems to work OK (limited testing)

G Estes
Ranch Hand

Joined: Oct 22, 2002
Posts: 62
Thanks for the response. Our JTable has several custom renderer/editors and while I can see that the selection is happening (i.e. I Shift+Tab then type and the text goes into the correct cell), the editor is not coming up on entry - as it does doing a normal Tab action. Any suggestions as to what may be different here?
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> Any suggestions as to what may be different here?

in the source code for JTable, in processKeyBinding(..) the event is passed
to the editor component.

perhaps this addition might be enough

table.changeSelection(row, column, false, false);
table.editCellAt(row,column);//<-------------
G Estes
Ranch Hand

Joined: Oct 22, 2002
Posts: 62
That was a good thought, but made no impact. Almost like I need to fire an event to trigger edit mode maybe?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JTable Tabbing