• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTable value changes  RSS feed

 
ram shyam
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a JTable in which I do some changes in the cells by opening a pop-up from each row of the JTable. Once the changes are made, the values are not reflected in the corresponding row, unless I select some other row.
What could be the issue in this?

Please clarify.

Thanks in advance!!
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You said you were changing the cells, but didn't provide any details about how. Are you calling the setValueAt() method of the table model to change the cells, or are you just changing the underlying data?
 
ram shyam
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I shall explain the entire design.

I have a JTable in which if I double-click a particluar row, a pop-up is displayed with the fields from the selected row. On changing these fields and pressing OK, the values are set back to the row using setValueAt(). Also, I display a JButton in one of the columns when the values are set back to the row.

But, only if I click any other row, the JButton and the changed values are getting reflected in the previously selected row.

Could you please help me in resolving this?

Many thanks in advance!!
 
Brian Cole
Author
Ranch Hand
Posts: 936
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by ram shyam:
I have a JTable in which if I double-click a particluar row, a pop-up is displayed with the fields from the selected row. On changing these fields and pressing OK, the values are set back to the row using setValueAt(). Also, I display a JButton in one of the columns when the values are set back to the row.

But, only if I click any other row, the JButton and the changed values are getting reflected in the previously selected row.


Your setValueAt() method should be calling fireTableCellUpdated(). For example, DefaultTableModel's implementation looks like this:


Sometimes in simple situations it's ok to omit the call to fireTableCellUpdated(), but your situation isn't simple enough.
 
ram shyam
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Many thanks for your reply.
Now, the values get reflected as soon as they are changed.

Once again thanks!!!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!