How can I get my JTable
to display my data row by row? As my data can be huge, up to thousands of rows, I want to display row by row so the user can see it being populated.
I've tried many different ways like paint
, repaint
, validate
, all the model.fire
... and more but still my table only shows the data after everything has been added in at the end. An example of how I'm doing the method:
public void updateTableRowByRow(String row) {
// length of row always equals cols
int cols = 16;
int i = 0;
DefaultTableModel model = (DefaultTableModel) gui.myTable.getModel();
Vector<String> rowData = new Vector<String>();
for (int c = 0; c < cols; c++) {
rowData.add(String.valueOf(row.charAt(i++)));
}
model.addRow(rowData);
// tried many things here to get it to refresh but nothing worked
}
Before I call this method, I would clear the table:
DefaultTableModel model = (DefaultTableModel) gui.myTable.getModel();
model.setRowCount(0); // delete all