如何从javafx中的另一个线程重新打开关闭的阶段

时间:2019-05-30 21:06:19

标签: java multithreading javafx

我有一个看起来像这样的Java应用程序:

@Override
public void start(Stage primaryStage) throws Exception {
    root.getChildren().add(FXMLLoader.load(getClass().getResource("FXML.fxml")));
    Scene scene = new Scene(root, 1680, 1050);

    stage = primaryStage;
    stage.setScene(scene);
    stage.setMaximized(true);
    stage.show();
    //some code
    stage.close();
    //normal java code in another class
}

public static void main(boolean first) {
    if (first) launch(new String[]{});
else{
//never prints hello, only hi
System.out.println("hi");
        Platform.runLater(new Runnable() {
        @Override public void run() {
            System.out.println("hello");
stage.show();
        }
    });
}
}

我的问题是:我该怎么做才能再次从另一个类打开fxml? 我尝试使用Platform.runLater(),但无法正常工作。 感谢您的帮助。

0 个答案:

没有答案
相关问题