简体   繁体   English

JavaFX后台设置

[英]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.当我登录时,我有一个简单的注销按钮,它再次将我带到相同的 fxml 以加载表单。 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);当用户退出scene.setFill(Color.TRANSPARENT); 时,您需要将场景的填充设置为透明。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM