do you know the best way to erase whole JT ?
+1
A:
It depends on your model. If you can access it, modify its content, else :
yourJTable.setModel(new DefaultTableModel());
Colin Hebert
2010-08-27 13:04:18
I did read your post, which is why I needed to answer the question correctly.
bluedevil2k
2010-08-27 15:28:20
+1
A:
Don't do it like HEBERT suggested, you break the link between your data object and your table model. Bad MVC design.
Ideally, you have access to the data model. Assuming it's a List in the variable myDataList
myDataList.clear();
myTable.getModel().fireTableDataChanged();
bluedevil2k
2010-08-27 14:08:46
Did you even read my post ? Your post is about the ideal situation, mine is about the worse case scenario...
Colin Hebert
2010-08-27 14:23:20
-1, you should not be modifying the "data list" which contains the data. You should modify the TableModel directly. The DefaultTableModel has a method setRowCount() method which will clear the data for you. If you have a custom model then you will need to add a clear() method which will then fire the table data changed method.
camickr
2010-08-27 15:28:04