user1381208
user1381208

Reputation: 61

How to create two windows simultaneously in JavaFX?

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?

Upvotes: 6

Views: 7831

Answers (1)

Sergey Grinev
Sergey Grinev

Reputation: 34498

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

Upvotes: 10

Related Questions