开发者

Detecting where a change event came from

开发者 https://www.devze.com 2023-01-12 18:45 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消