aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes [JTable] problem with edition in a JTextField Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "[JTable] problem with edition in a JTextField" Watch "[JTable] problem with edition in a JTextField" New topic
Author

[JTable] problem with edition in a JTextField

Nicolas Daudin
Greenhorn

Joined: Dec 19, 2007
Posts: 12
Hi there,
I have a JXTable that contains a column called "Delay".
Delay is a Label when it is not edited, and a JTextField upon edition.
I have a few lines in my JXTable.
When i click on my first Delay cell, i enter a value, then i press Enter and i get the focus on the next JTextField, and all the text is selected to be replaced (with this trick


Problem is, if i press the up arrow key or the down arrow key, the selected cell is the right one, but it is not in mode edition anymore (i.e. the JLabel appears, not the JTextEdit) and the focus is not on the field anymore but on the JXTable.
If i start inputing something, it adds to the value already present in the field: ex : if there was 24, i go on this cell from the previous one using Enter, i write 5, at the end i have 5. If i go on this cell from the previous one using the arrows, and i write 5, at the end i get 245. And i want the automatic selection as well for the Up and Down arrow keys cases.

Please help me
Balasubramanian Chandrasekaran
Ranch Hand

Joined: Nov 28, 2007
Posts: 215

Then you need to override your Up and Down keyevents. That will give your desired result.
Nicolas Daudin
Greenhorn

Joined: Dec 19, 2007
Posts: 12
And how can i do this?
By a field.addKeyListener()...?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: [JTable] problem with edition in a JTextField