Issue with background color in JavaFX 8

Sirish V picture Sirish V · Mar 24, 2014 · Viewed 107k times · Source

Looks like there is an issue with setting background colors for panels in JavaFX 8.

I had been trying the below, but none of them set the appropriate background colors.

VBox panel = new VBox();
panel.setAlignment(Pos.TOP_LEFT);

// None of the below work
panel.setStyle("-fx-background-color: #FFFFFF;");
panel.setBackground(new Background(new BackgroundFill(Color.WHITE, CornerRadii.EMPTY, Insets.EMPTY)));

Is there something wrong in the way I am setting the background color? This used to work with earlier versions of JavaFX 2.2.

Thanks.

Answer

Sirish V picture Sirish V · Jul 9, 2014
panel.setStyle("-fx-background-color: #FFFFFF;");