Java – what is the best way to listen for changes in JTable cell values and update the database accordingly?
•
Java
I am using multiple JTable builds and applications, and I need to detect when cell values change so that I can update it in the database I tried tablemodellistener and rewritten tablechanged, but it will only be triggered when I click (click another row) after editing the cell
Is there any other way?
Solution
You can implement the celleditorlistener interface, as shown in example Note that JTable itself is celleditorlistener
It is also convenient to terminate editing when focus is lost:
table.putClientProperty("terminateEditOnFocusLost",true);
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码