javafx之新建窗口和启动另外一个程序

在javafx中一个JVM进程只能存在一个Application类,这个Application类只能调用一次launch()方法来启动它。

那我们如果启动一个新的窗口呢?

javafx中Stage类继承了Window代表着一个窗口,所以我们只需要构造一个Stage并将之显示即可。

Stage secondWindow=new Stage();
Scene scene=new Scene(root,300,275);
secondWIndow.setTitle("secondWindow");
secondWindow.setScene(scene);
secondWindow.show();

如果你需要启动另外一个javafx程序,则可以这样:

   Platform.runLater(new Runnable() {
       public void run() {             
           new anotherApp().start(new Stage());
       }

    原文作者:小小懒羊羊
    原文地址: https://blog.csdn.net/xby1993/article/details/24740631
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞