posted 14 years ago
Hi,
I have two JSpinner which represent the width and the height of an image. These values can be manipulated freely unless "Maintain ratio" checkbox is selected. Then, when e.g. width changes, the height value is changed accordingly automatically using the previously calculated size ratio for the image.
This little program represents the idea (I hard-coded the size ratio):
I attached changes listeners to both JSpinners so that when one value is changes, the value of the other JSpinner can be changed in response. The problem is that the stateChanged function is called also as a result of this automatic ratio adjustment, so that everything gets messed up. I was wondering how I could make this properly... Is there a way of firing the stateChanged event only when the value is changed by user input, not when it is changes programatically by ratio adjustments?
I would really appreciate some help. Thank you!