• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Editing a Cell in JTable

 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Author
Posts: 986
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
We should throw him a surprise party. It will cheer him up. We can use this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic