tags:

views:

74

answers:

2

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
I did read your post, which is why I needed to answer the question correctly.
bluedevil2k
+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
Did you even read my post ? Your post is about the ideal situation, mine is about the worse case scenario...
Colin Hebert
-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