Home > Software design >  How to change JavaFX slider thumb color without CSS
How to change JavaFX slider thumb color without CSS

Time:08-15

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.

CodePudding user response:

You could use the -fx-base property:

Example:

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

Slider example

However why don't you consider using a CSS file? It simplifies everything and allows you do 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