简体   繁体   中英

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.

You could use the -fx-base property:

Example:

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

滑块示例

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM