[英]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.我正在使用 ScalaFX,它目前证明自己完全没用,并且在我尝试使用 css 的任何时候都会出错。 Is there any way to change the fill color of a
Slider
without using css, or at least without separate css files?有没有办法在不使用 css 或至少不使用单独的 css 文件的情况下更改
Slider
的填充颜色?
I've managed to change the track color with slider.setStyle("-fx-control-inner-background: #f08080;")
, but can't get the thumb working.我已经设法用
slider.setStyle("-fx-control-inner-background: #f08080;")
改变了轨道颜色,但无法让拇指工作。
You could use the -fx-base
property:您可以使用
-fx-base
属性:
Example:例子:
slider.setStyle("-fx-base: #f08080;");
However why don't you consider using a CSS file?但是,您为什么不考虑使用 CSS 文件呢? 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.
看看Slider JavaFX CSS 参考,我想你会找到你想要的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.