Detecting where a change event came from
I have a bunch of JTextComponents that fire update events to a common model. The model then fires out change events to the other components so they can all be in synch. How can I detect which one fired the event initially so as not to fire the event back? I ask this as I'm c开发者_StackOverflow社区urrently getting an expection due to attemtping to update the component that fired the event.
There should be a getSource
method on the event object. Use that to obtain a reference to the component that originally fired the event. You can then skip that component when distributing the event.
精彩评论