You must remove the data from the TableModel
used for the table.
If using the DefaultTableModel
, just set the row count to zero. This will delete the rows and fire the TableModelEvent
to update the GUI.
JTable table;
…
DefaultTableModel model = (DefaultTableModel) table.getModel();
model.setRowCount(0);
If you are using other TableModel
, please check the documentation.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…