merlachandra
merlachandra

Reputation: 386

How enable/disable calling tableChanged(TableModelEvent e) method of AbstractTableModel

The method tableChanged(TableModelEvent e) of TableModelListener is getting called whenever data is loaded into table from a CSV file. I don't want this to happen.

I want tableChanged(TableModelEvent e) of TableModelListener to be called only when table rows are added or when some cell data is updated manually.

Can Somebody tell me how this can be achieved?

Thanks in Advance!

Upvotes: 0

Views: 716

Answers (1)

trashgod
trashgod

Reputation: 205865

One approach is to create a new TableModel, to which no JTable is listening. Update the table using setModel(), which will generate a single TableModelEvent. A minimal complete example is seen here.

Alternatively, remove and restore the problematic TableModelListener.

Upvotes: 3

Related Questions