switch to editor when renderer gets focus  
Author Message
doubleought77





PostPosted: 2004-12-18 1:21:00 Top

java-programmer, switch to editor when renderer gets focus 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

 
John McGrath





PostPosted: 2004-12-19 8:33:00 Top

java-programmer >> switch to editor when renderer gets focus On 12/17/2004 at 12:21:06 PM, email***@***.com wrote:

> 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) ?

--
Regards,

John McGrath
 
doubleought77





PostPosted: 2004-12-20 23:14:00 Top

java-programmer >> switch to editor when renderer gets focus
John McGrath wrote:
>
> Have you tried table.setSurrendersFocusOnKeystroke(true) ?
>
> --
> Regards,
>
> John McGrath

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

 
 
doubleought77





PostPosted: 2004-12-25 0:10:00 Top

java-programmer >> switch to editor when renderer gets focus
email***@***.com wrote:
> John McGrath wrote:
> >
> > Have you tried table.setSurrendersFocusOnKeystroke(true) ?
> >
> > --
> > Regards,
> >
> > 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.

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

 
 
John McGrath





PostPosted: 2005-1-4 9:17:00 Top

java-programmer >> switch to editor when renderer gets focus On 12/24/2004 at 11:09:35 AM, email***@***.com wrote:

> 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.

--
Regards,

John McGrath