Erase All JTable

Do you know the best way to erase all JT?

+3
source share
2 answers

Do not do this, as HEBERT suggested, you are breaking the connection between your data object and your table model. Bad MVC design.

Ideally, you have access to a data model. Assuming this is a List in myDataList variable

myDataList.clear();
myTable.getModel().fireTableDataChanged();
+1
source

It depends on your model. If you can access it, change its contents, otherwise:

yourJTable.setModel(new DefaultTableModel());
+3
source

Source: https://habr.com/ru/post/1761919/


All Articles