Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Editing a Cell in JTable  RSS feed

 
Harjit Singh
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

I have a JTABle and 2 button under the table. When I edit a cell and Enter value with the cursor in the cell and hit the Button. I don't get the new value in the cell. If I click outside the cell (say the next cell) and then hit the button, I do get the new value. Is this the default behavior of JTable ?

Thanks

- Harjit
 
Brian Cole
Author
Ranch Hand
Posts: 949
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Harjit Singh:
I have a JTABle and 2 button under the table. When I edit a cell and Enter value with the cursor in the cell and hit the Button. I don't get the new value in the cell. If I click outside the cell (say the next cell) and then hit the button, I do get the new value. Is this the default behavior of JTable ?


Try yourTable.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE) and see if it helps.

Alas, this is poorly documented.
 
Ryan Muster
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes JTable wants the user to press enter before it takes it.
I have this in one of my programs
JTable.putClientProperty(\"terminateEditOnFocusLost\", Boolean.TRUE); //make it like excel

Now when the cell looses focus it should save it.
I have no idea how we figured that out...

I just downloaded the SwingLab widgets.
Hoping that SwingLabs will be a little more intuitive
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!