# Slider with changing image

**URL:** <https://forum.juce.com/t/slider-with-changing-image/47673>\
**Category:** Audio Plugins\
**Created:** [September 5, 2021, 1:06am UTC](https://forum.juce.com/t/slider-with-changing-image/47673 "2021-09-05T01:06:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Haydonc](https://avatars.discourse-cdn.com/v4/letter/h/f14d63/32.png) [@Haydonc](https://forum.juce.com/u/Haydonc)\
**Post date:** [September 5, 2021, 1:06am UTC](https://forum.juce.com/t/slider-with-changing-image/47673/1 "2021-09-05T01:06:39Z")

</div>

Hi,

I have a slider which uses a png of an LED within it. I have a button in the plugin which enables/disables the slider and accordingly have 2 pngs of the LED where it is either on/off.  
The slider is drawn via the `drawLinearSlider()` function inside the LookAndFeel class but I can’t figure out how to dynamic change the png used for the slider?

Thanks,

Haydon

---

<div class="post-metadata">

**Author:** ![rory](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/rory/32/534_2.png) [@rory](https://forum.juce.com/u/rory)\
**Post date:** [September 5, 2021, 10:09am UTC](https://forum.juce.com/t/slider-with-changing-image/47673/2 "2021-09-05T10:09:56Z")

</div>

If you enable/disable the slider with your button you can check its enabled state in your LookAndFeel method called calling

`slider.isEnabled()`

Then pick your image accordingly. You can also set properties for your slider object, which you can also pick up in your LookAndFeel class. So if you wanted to set the image when your button is called you could do something like this:

```auto
slider.getProperties().set("currentImage", "LED1.png"));
repaint();

```

and then in your LookAndFeel method:

`slider.getProperties().getWithDefault("currentImage", ").toString()`

I think the first approach is simpler.

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [September 6, 2021, 10:36am UTC](https://forum.juce.com/t/slider-with-changing-image/47673/3 "2021-09-06T10:36:20Z")

</div>

Maybe I misunderstood you, but if your slider has only two states, it sounds you actually wanted to use an [ImageButton](https://docs.juce.com/master/classImageButton.html).  
Just enable setClickingTogglesState() or similar. It is a common method for all button subclasses.

---

<div class="post-metadata">

**Author:** ![rory](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/rory/32/534_2.png) [@rory](https://forum.juce.com/u/rory)\
**Post date:** [September 6, 2021, 11:02am UTC](https://forum.juce.com/t/slider-with-changing-image/47673/4 "2021-09-06T11:02:58Z")

</div>

I wondered about this too, but I think the slider is still a slider, only with the addition of an on/off LED. 🤔
