I have a GUI that is issuing commands to a web server based on slider values. Some of these sliders are "coupled" on the web server, so changing one of them may also change another one. The coupling is accomplished by the web server returning a list of the values that were set based on the the issued command.
So I can easily set the appropriate sliders based on this response, but the issue is that doing this causes the ChangeListener to be fired and then a command is issued to the web server again. Ideally, the "coupling" should be well behaved and avoid infinite loops, but that is a potential concern and send all those extra events seems unnecessary.
The two solutions I could think of were:
- Temporarily removing the listeners, changing the value, and then putting them back.
- Add a "manual" flag to let the listener know that it should ignore the change.
Neither of those seems like the ideal solution to me, but is one of them "better" than the other? Or is there a third solution that I'm not considering?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…