Can anyone explain why my scene loses color the moment I create a button in JavaFX?
The following code works, with the background of the scene changing to red
@Override
public void start(Stage primaryStage){
//Set Primary stage title and create a rootNode
primaryStage.setTitle("Hello World");
FlowPane rootNode = new FlowPane();
//Create a scene and add it to the rootNode
Scene myScene = new Scene(rootNode, 300, 200, Color.RED);
//Add the scene to the stage
primaryStage.setScene(myScene);
//Show the stage
primaryStage.show();
}
However, the moment I create another control, like a button in the example below (and I don't even have to add it to the flowpane), the color reverts back to grey.
@Override
public void start(Stage primaryStage){
//Set Primary stage title and create a rootNode
primaryStage.setTitle("Hello World");
FlowPane rootNode = new FlowPane();
//Create a scene and add it to the rootNode
Scene myScene = new Scene(rootNode, 300, 200, Color.CORAL);
Button newBtn = new Button();
//Add the scene to the stage
primaryStage.setScene(myScene);
//Show the stage
primaryStage.show();
}
Anyone know why this is? Am I trying to change the background color incorrectly?