Domanda

java JTable, diciamo che ho un enorme JTable (800 * 50) con AbstractTableModel.Ora voglio rimuovere tutte le righe della tabella e inserire nuove righe di dati in quella tabella.Qual è il modo più semplice e ad alte prestazioni per raggiungere questo obiettivo?

Grazie.

È stato utile?

Soluzione

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 );
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top