• 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
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

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
 
To get a wish, you need a genie. To get a genie, you need a lamp. To get a lamp, you need a tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic