• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Table Model data not getting updated after JTable looses focus

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I have a jtable, created a table model and a table cell editor.
The cell editor is JTextField. When I click on any cell, it turns to text field and I edit the contents.
When I click on another cell, the content of the text field reflected to the table model.
But when I click on any JButton outside the table after editing the text in the text field inside the cell,
the contents are not reflecting in the model.

In my table model setValue(), I called the fireTableDataChanged() method.

Please help me.
 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This can be achieved by calling cancelCellEditing() of the DefaultCellEditor, as soon as you know that the update on the table cell is over.
 
Sanjeev Debnath
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sugantha

Thank you for the reply.
But its not working. I tried your suggestion, but after entering value in textfield which is a cell,
I clicked on the button and the textfield/cell's content disappeared and returning to the same situation.
 
Marshal
Posts: 22450
121
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try this:
It's one of the, unfortunately, hidden features in Swing.
 
Sanjeev Debnath
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Rob,

Thanks a lot!!!
You save my day.

It fixed my problem.

Thanks again....
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic