How to handle JTable data changed event

10.9k Views Asked by At

I have a JTable bound to a List property. I used NetBeans to add a property to my jpanel form, enabled/checked propertyChangeSupport, and bound my jTable to that property. Table is displaying the data perfectly. Please guide me how can I enable/disable a 'Save' button when data of this table is changed by double-clicking a cell and editing its contents.

2

There are 2 best solutions below

0
On BEST ANSWER

The Table Cell Listener will listen for real changes in the data of a cell.

A TableModelListener fires an event even if you tab out of the cell and don't actually change the data.

1
On

Have you tried adding a TableModelListener to the JTable's model? This should fire any time the table's data is changed, and the listener can then enable your save button. The button should disable itself whenever it is pressed and the data has been successfully saved.

Edit:
Please ignore this and instead go with camickr's recommendation!