• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

fireTableDataChanged ()

 
kamiya sei
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following is a small snippet of my code, I wonder method fireTableDataChanged () when I use it and are necessary when working with JTable ???

tbModel = new DefaultTableModel(data, header);
tbModel.fireTableDataChanged();
tblStudent.setModel(tbModel);
btnSearch.setEnabled(true);

Regards.
Kamiya Sei
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In that particular case, no, there is no point in calling "fireTableDataChanged" on a table model which has just been created and has had no changes yet.

There are times when you need to call it -- that's why the method exists, of course -- but that is not one of those times.
 
Nam Ha Minh
Ranch Hand
Posts: 504
Eclipse IDE Firefox Browser Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I usually use fireTableDataChanged() after making some changes to the table model. Without that call, the table GUI doesn't get updated.
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nam Ha Minh wrote:I usually use fireTableDataChanged() after making some changes to the table model. Without that call, the table GUI doesn't get updated.


I guess you're talking about a custom (and possibly badly implemented) TableModel. The posted code shows a DefaultTableModel -- which takes care of firing changes without any outside assistance.

Moreover, as Paul said, no changes have been made to the data; additionally, the model is not associated with any JTable so in any case it won't have any listeners that might respond to fireTableDataChanged().
 
Nam Ha Minh
Ranch Hand
Posts: 504
Eclipse IDE Firefox Browser Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Darryl Burke wrote:

I guess you're talking about a custom (and possibly badly implemented) TableModel. The posted code shows a DefaultTableModel -- which takes care of firing changes without any outside assistance.

Moreover, as Paul said, no changes have been made to the data; additionally, the model is not associated with any JTable so in any case it won't have any listeners that might respond to fireTableDataChanged().


Sorry, my answer did not target to context of the OP's example. I meant using a custom table model which is associated with a table.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic