Java Swing TableModel fireTableRowsInserted on EDT

I have a TableModel that is being populated by a background thread. I call fireTableRowsInserted when data is inserted, which is NOT on EDT.

My question is, do I need to use invokeLater for fireTableRowsInserted?

In other words, this is correct:

public void putData(TableRow row) {
    // we are not on the EDT here...
    rows.add(row);
    fireTableRowsInserted(rows.size()-1, rows.size()-1);
}

      

+2


a source to share


1 answer


Well, since this event can cause the table to be redrawn, it should be in the EDT, yes. But you can rely on SwingUtilities.invokeLater

to only have the relevant part called in the EDT.



+2


a source







All Articles