How to create two windows simultaneously in JavaFX?


Question

I tried this one JavaFX 2.0 subwindow but the problem is, there is only one Stage can repaint(refresh), the other one just frozen, if you put some button on that stage, you will find that the button didn't show "over" and "press" picture, how to solve this?

1
6
5/23/2017 12:14:17 PM

Did you created new Stage on the "JavaFX Application Thread"?

Try next:

    javafx.application.Platform.runLater(new Runnable() {

        @Override
        public void run() {
            Stage stage = new Stage();
            stage.setScene(new Scene(new Group(new Button("my second window"))));
            stage.show();
        }
    });

All FX UI operations should be executed on "JavaFX Application Thread", see http://docs.oracle.com/javafx/2/architecture/jfxpub-architecture.htm#sthref8

10
5/8/2012 6:39:01 AM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon