简体   繁体   中英

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.

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.

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM