Khalid Amin
Khalid Amin

Reputation: 902

How to handle JTable data changed event

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.

Upvotes: 1

Views: 11112

Answers (2)

Hovercraft Full Of Eels
Hovercraft Full Of Eels

Reputation: 285403

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!

Upvotes: 1

camickr
camickr

Reputation: 324118

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.

Upvotes: 5

Related Questions