简体   繁体   中英

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 . 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:

    borderPane.getStyleClass().add("env-pane");

and css like this:

.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.

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.

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