[英]Setting background color for BorderPane works in line but not within CSS file
So I have a border pane and I want to set it's background color with -fx-background-color: black
.所以我有一个边框窗格,我想用
-fx-background-color: black
设置它的背景颜色。 When I do this 'inline' like this:当我像这样“内联”时:
borderPane.setStyle("-fx-background-color: black");
it works fine, but if I instead add a class selector to it and try setting the color within the selector, like this:它工作正常,但如果我改为添加一个 class 选择器并尝试在选择器中设置颜色,如下所示:
borderPane.getStyleClass().add("env-pane");
and css like this:和 css 像这样:
.env-pane {
-fx-background-color: black;
}
No changes take place.不会发生任何变化。 I'm not sure if this is related.
我不确定这是否相关。 Looking at the Javafx css reference the pane class has the
-fx-background-color
property.查看 Javafx css 参考窗格 class 具有
-fx-background-color
属性。
If it helps, I added the style sheets to the scene and other components change based off of it fine.如果有帮助,我会将样式表添加到场景中,并且其他组件会根据它进行更改。
I tried to re-create your problem but seems like it works for me.我试图重新创建您的问题,但似乎它对我有用。 I'm using JDK 8 by the way.
顺便说一句,我正在使用JDK 8。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.