Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JTable AbstractCellEditor loses first keystoke

843805Jan 9 2006 — edited Jan 12 2006
I have extended AbstractCellEditor to return a JPanel on getTableCellEditorComponent(). The JPanel contains a JTextField (positioned to left or right side of the pane depending on dr/cr).

Focus with the mouse works as expected.

My problem occurs when tab is used to select the cell

Pressing a key causes the JPanel FocusListener() to send grabFocus() to the JTexField which commences editing.

That invoking keystroke is lost, instead of being passed on to the JTextField (in the same manner as the String cell editor would, for example).

I tried a KeyListener on the JPanel, but this never sees a KeyEvent. A KeyListener on the JTable capturing every keystroke could work but seems a bit over-engineered (a la Mickey Mouse).

Is there a simple way of getting a hold of that keystroke and passing it on?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 9 2006
Added on Jan 9 2006
7 comments
101 views