简体   繁体   中英

JavaFX background Setting

I am making a simple software to Reserve Stadium Seats. I have a main page wish is the Login Page. I have a simple design. With a transparent background just to give it a form. As you can see in the image below. 在此处输入图像描述 As you can see the code can bee seen behind the form. When i login i have a simple logout button that takes me again to the same fxml to load the form. but this time the background is no longer transparent: 在此处输入图像描述 . As you see here it is green. it is by default white but i was trying to make it transparent again. this is the code i tried to do:

public void logoutButton (ActionEvent event) throws IOException {
    Parent root = FXMLLoader.load(getClass().getResource("Main.fxml"));
    Stage stage = (Stage)((Node)event.getSource()).getScene().getWindow();
    Scene scene = new Scene(root);
    root.setStyle("-fx-background-color: #20825170;");
    stage.setScene(scene);
}

even changing the style to transparent wont work i tried it. any help?

You need to set the fill of the scene to transparent when a user logs out scene.setFill(Color.TRANSPARENT);

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