我有一个会弹出新阶段的按钮,但初级阶段不会禁用它仍然可以单击,所以如何禁用初级阶段。
这是我的舞台和场景代码
private static final Stage stage = new Stage();
private static final Stage newstage = new Stage();
/**
*
*/
@Override
public void start(Stage primaryStage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("MainMenu.fxml"));
Scene scene = new Scene(root);
scene.getStylesheets().addAll(this.getClass().getResource("background.css").toExternalForm());
stage.setScene(scene);
stage.show();
}
public void chgScene (String str) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource(str));
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
}
public void addStage (String str) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource(str));
Scene scene = new Scene(root);
newstage.setScene(scene);
newstage.setResizable(false);
newstage.showAndWait();
}
public void clearStage () {
newstage.close();
}
如果有任何错误,非常抱歉,因为我是 Java 的新手,我需要为我的项目创建一个 GUI。感谢您的帮助。
最佳答案
关于java - 当新阶段弹出时,我如何禁用初级阶段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34070334/