I don't know if this is possible. I have a data structure that is displayed in various tabbed panels in various forms(JList/JCheckList etc.). Some of these panels are able to manipulate the data structure. Is there a way to attach some sort of ActionListener to data structure so whatever class has a copy of it will know that a change has occured and recreate the display?

Please advise.

12 Years
Discussion Span
Last Post by MattEvans

You should know when the data is going to change. Encapsulation isn't the best thing in the world, but it does let you notice changes in things. Your "data structure" should have methods that allow users to write to it, when these methods occur you can invoke an action in something "listening" to it. The observer class doesn't really do (or observe) anything!

If your data is modified outside the application you have to poll it for changes... or add some kind of OS hook that notifies your app; better still, only let your data structure be changed using a self-agreed protocol that involves notifying your "observing" program.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.