How to change JavaFX slider thumb color without CSS

Viewed 109

I'm using ScalaFX, which is currently proving itself to be thoroughly useless and bugging out anytime I try to use css. Is there any way to change the fill color of a Slider without using css, or at least without separate css files?

I've managed to change the track color with slider.setStyle("-fx-control-inner-background: #f08080;"), but can't get the thumb working.

1 Answers

You could use the -fx-base property, which sets the component colors palette according to the value you specify.

Example:

slider.setStyle("-fx-base: #f08080;");

Result:

Slider example

However why don't you consider using a CSS file? It simplifies everything and allows you to make a lot more customizations. Take a look at the Slider JavaFX CSS reference, I think you will find what you're looking for.

Related