I'm trying to build a Swing app where one window/JFrame has a listing of database records, and another window/JFrame has a detail form to edit one of those database records.
I've got the listing window working with a JTable, backed by a database RowSet, with a TableModel in between based on George Reese's JDBC book's code. Beneath the JTable are buttons to add or edit a row in the JTable. These buttons open a separate JFrame to use as a detail form.
My question is: How can I coordinate data changes?
The RowSet could possibly be re-populated, leaving out our particular record in the detail form.
So are listeners the way to go? Or should I look at something more loosely coupled? Such as creating my own event bus to have each widget subscribe to events related to a particular table. Then each widget would look at each notification to see if the record id mentioned in the notification is a record of interest.
posted 5 years ago
I believe you could try to use java.util.Observer/java.util.Observable functionality or indeed write your own event handling mechanism.