This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Table Model data not getting updated after JTable looses focus

 
Sanjeev Debnath
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • 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.
 
Sugantha Jeevankumar
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Rob Spoor
Sheriff
Pie
Posts: 20665
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Hi Rob,

Thanks a lot!!!
You save my day.

It fixed my problem.

Thanks again....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic