so I have a JSlider that has a custom synth look and feel, that looks like this (in xml):
<!-- Make and Bind a SliderTrack style -->
<style id="SliderTrackStyle">
<opaque value="FALSE"/>
</style>
<bind style="SliderTrackStyle" type="region" key="sliderTrack" />
<!-- Make and Bind a Vertical Slider Thumb style -->
<style id="verticalSliderThumbStyle">
<state>
<imagePainter method="sliderThumbBackground" path="/resources/images/slider/SliderThumbVertical.png"
sourceInsets="0 0 0 0"/>
</state>
<state value="PRESSED">
<imagePainter method="sliderThumbBackground" path="/resources/images/slider/SliderThumbVerticalPressed.png"
sourceInsets="0 0 0 0"/>
</state>
</style>
<bind style="verticalSliderThumbStyle" type="name" key="VerticalSlider.*" />
Now, this works nicely, and the JSlider looks like it should. I'm then controlling the value of the slider programatically, using slider.setValue();
I can also fire the mouse listeners on the slider programatically, since it has some code that is executed right when the slider is clicked and when it's released. Again, this all works well. However, I can't seem to figure out how to tell the slider to look pressed when the value is changing. Is there a way to tell swing to make the slider look pressed even though it's not physically pressed (trigger the PRESSED
state in the L&F)?
EDIT: I can make this work by using a DISABLED
state, which has the same look as the pressed state. I can then disable the slider, move it around, and enable it again later. Obviously, that's a pretty hacky way to achieve the pressed look. Any other ideas would be appreciated.