0

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!

trashgod
  • 203,806
  • 29
  • 246
  • 1,045
merlachandra
  • 376
  • 2
  • 17
  • 1
    the listener _must_ be notified, you can't and must not disable that call. The way to go is a listener implementation that is intelligent enough to detect when/if it should do anything with the notification. Chances are that you are doing something suboptimal in your model, consider posting a SSCCE demonstrating what you want to achieve and explain _why_ you want it – kleopatra Jul 30 '13 at 07:27

1 Answers1

3

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.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045