JTable - Getting a cell into Edit mode on pressing Tab
Posted
by Luhar
on Stack Overflow
See other posts from Stack Overflow
or by Luhar
Published on 2010-06-10T09:26:51Z
Indexed on
2010/06/10
9:33 UTC
Read the original article
Hit count: 252
This is possibly has a trivial solution, but I am at the end of my tether so I hope somebody can help out.
I use a JTable which has a custom renderer and a custom editor for a set of columns.
The renderer uses a JLabel component and the editor uses a JSpinner component.
Our users want to be able to enter values in a column, and then press TAB or ENTER to move to the next editable cell in the table.
If I understand correctly, this is the default behaviour for a JTable.
However, this doesn't seem to work correctly for me. Until the user clicks on the cell, only the JLabel is displayed.
The JSpinner (i.e. CellEditor) is only displayed when a user double clicks on the cell. So, it looks like the cell is going into "edit" mode only on MouseEvents, but not when it has focus.
How do I get the cell to go into edit mode as soon as it has focus?
© Stack Overflow or respective owner