Java save changes
I have an application that mainly includes JList displayed on the screen I hope that whenever I make changes to the abstractlistmodel (add or delete items to the list), I will somehow notify the application that the changes have been made and change the title of the JFrame to be similar to the frame_ The content of the title [unsaved] After I save the application, the [unsaved] tag will disappear
@H_ 301_ 8@
I think maybe using observer / observable technology can do this, but I don't know what to do Maybe there are some more suitable questions for me? I'm new to Java, so I'm here for help Thank you@ H_ 301_ 8@
Update: I can't really use observer pattern because I'm already extending the abstractlistmodel class@ H_ 301_ 8@
Solution
Use this:
@H_ 301_ 8@
@H_ 301_ 8@
AbstractListModel model = ...; model.addListDataListener(new ListDataListener() { public void intervalAdded(ListDataEvent e) { } public void intervalRemoved(ListDataEvent e) { } public void contentsChanged(ListDataEvent e) { } });