I have a JSlider component on my frame which is being constantly updated by an external component (a media player which sets a new value from time to time). I want the slider to handle the stateChanged event only when I manipulate the slider and not my external component.
Is there any way to achieve this?
I’d implement my own BoundedRangeModel, this way you can add additional flags that indicates whether it should accept updates or not
UPDATE with EXAMPLE
The basic idea would be to implement your own model, that way you can control when the value is actually changed
This would allow you to control the change of the “value” property. The problem you have here is that ALL the set methods go through the
setRangePropertiesmethod, so you need to decide what should be allowed to effect it. In my example, the only method that does not control it is thesetValuemethod.In your code you would need to call it something like…
Your only other choice is to extend the
JSlideritself and override thesetValuemethod directly in a similar way