Question

java JTable, Say I have a huge JTable (800*50) with AbstractTableModel. Now I want to remove all table rows and put new data rows into that table. Which way is easiest and high-performance way to achieve this ?

Thanks.

Was it helpful?

Solution

The AbstractTableMoeel doesn't support this. If you extend the AbstractTableModel to create a custom model then you need to implement this method yourself.

Or you can use the DefaultTableModel which implements a setRowCount() method. So you can reset the rows to 0. You can then use the insertRow(...) method to add new rows.

However the easier way is to probably just create a new TableModel. Then you can refresh the table by using:

table.setModel( newlyCreatedModel );
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top