switch to editor when renderer gets focus

D

doubleought77

I have a jcombobox as an editor inside a jtable.
I would like to switch to the editor as soon as they enter the column
with the jcombobox in it so they can start editing right away.
This is an editable jcombobox, so when tabbing through the columns in
the jtable, the first key stroke only activates the editor -- so the
second keystroke is being used instead of the first.

entering the column with the jcombobox in it, you have to hit the space
bar or the enter key before you can type in the jcombobox editor.
Otherwise, if you start typing "Smith" in the column, the "S" activates
the combobox editor and the list jumps to the "m" section instead of
the "s" section.

Appreciate the help. TIA
 
J

John McGrath

entering the column with the jcombobox in it, you have to hit the space
bar or the enter key before you can type in the jcombobox editor.
Otherwise, if you start typing "Smith" in the column, the "S" activates
the combobox editor and the list jumps to the "m" section instead of
the "s" section.

Have you tried table.setSurrendersFocusOnKeystroke(true) ?
 
D

doubleought77

John said:
Have you tried table.setSurrendersFocusOnKeystroke(true) ?

I use it all the time. It is especially useful for changing the editor
to the renderer on columns that are no longer being edited. However,
it has no effect for changing the renderer to the editor on columns
that have focus.

THX
 
D

doubleought77

I played around enough until I found a solution.
Over-ride the columnSelectionChanged event and set the selected cell
into edit mode. This will work when clicking on a cell or entering it
via TAB keys or arrows.

public void columnSelectionChanged(ListSelectionEvent e) {
super.columnSelectionChanged(e);
editCellAt(getSelectedRow(), getSelectedColumn());
}
 
J

John McGrath

I played around enough until I found a solution.
Over-ride the columnSelectionChanged event and set the selected cell
into edit mode. This will work when clicking on a cell or entering it
via TAB keys or arrows.

That sounds like it would only work when you change columns. You could
move to a cell in the same column using up or down arrow key.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top