Nabin Raj Pandey
Nabin Raj Pandey

Reputation: 21

To refresh JTable JAVA

I wanted to refresh JTable immediately when data is inserted or deleted ,i got problem looked at forums but the solutions are too particular to their examples,is there a general way how JTable is refreshed on any event on same page happens? specially when the event changes data upon which the table model relies..

Upvotes: 2

Views: 3312

Answers (1)

camickr
camickr

Reputation: 324078

Updates should be done directly to the TableModel. The model will then notify the table so the table can repaint itself.

If you are using a custom TableModel, then it is your responsibility to make sure the proper fireXXX() methods inherited from the AbstractTableModel are invoked when the TableModel is changed.

Using the DefualtTableModel is an easy way to start since it does all this for you.

Upvotes: 5

Related Questions