【发布时间】:2016-03-08 07:45:11
【问题描述】:
我有按钮会弹出新阶段,但主要阶段不会禁用它仍然可以单击,所以如何禁用主要阶段。
这是我的舞台和场景代码
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 javafx javafx-8 fxml scenebuilder