Update LookAndFeelSlider method dynamically

Currently I have overriden a slider using LookAndFeel_V3 and I want to redraw the slider background dynamically (redraw the background or foreground slider too if needed). The slider is read only to simplify the requirements.

How would I do this? Is instantiating a laf object and calling laf.drawLinearSliderBackground possible? I know this might be computationally expensive to redraw the background of the slider, but my update will be minimal and this is an experiment at designing dynamic GUIs. Any ideas?

just call it’s repaint() function. This will cause the component to have it’s paint() function called (async from your call to repaint()).

I’m sorry, I didn’t quite get this.

Do you mean calling the slider’s repaint() function would call the drawLinearSlider which in turns calls drawLinearSliderBackground?

I would also like to access some data while redrawing the background. So i was hoping to
laf.setData(4); slider.repaint();
Then access the data in laf.drawLinearSliderBackground()

I do not fully understand all the other trickery you want to do, but if you want to repaint the background of your slider, yes, called mySlider.repaint()

The LookAndFeel is shared by all your Components (or at least many Components, you can have multiple LookAndFeels). So the LnF should be stateless. It only defines behaviour, not a state of a specific slider.

However you can use the getProperties() NamedValueSet, that every Component has, and in your LnF implementation you get a reference to the coponent that is calling your drawSliderBackground or whatever, it can access these properties.