J
Jason Cavett
I was wondering if anybody here has implemented multiple (Swing) views
to a common model.
I'm currently doing this, and I'm having an issue where
1. I update the model via the first view (type some text into a text
box)
2. a listener on the text box sets the data in the model
3. the model fires a notification (per Observer pattern) because its
data has changed and
4. the second view is updated.
However, when the fields in the second view are updated, THEIR own
listeners fire off and the underlying model is set again, and proceeds
to repeat the above sequence (but flipped for the views) so the GUI
falls into an infinite loop.
Has anybody ever run into this issue before? How did you handle it?
(For now, I have a flag checking to see if the notification should be
fired or not, but it's not very robust or extendable and is causing
its own set of problems.)
I'm open to suggestions. Thanks!
to a common model.
I'm currently doing this, and I'm having an issue where
1. I update the model via the first view (type some text into a text
box)
2. a listener on the text box sets the data in the model
3. the model fires a notification (per Observer pattern) because its
data has changed and
4. the second view is updated.
However, when the fields in the second view are updated, THEIR own
listeners fire off and the underlying model is set again, and proceeds
to repeat the above sequence (but flipped for the views) so the GUI
falls into an infinite loop.
Has anybody ever run into this issue before? How did you handle it?
(For now, I have a flag checking to see if the notification should be
fired or not, but it's not very robust or extendable and is causing
its own set of problems.)
I'm open to suggestions. Thanks!