Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to change JavaFX slider thumb color without CSS

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading