How can i clear the content of the JTable using Java..
See Question&Answers more detail:osYou 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.