Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 527
user1381208 Avatar asked May 08 '12 05:05

user1381208


1 Answers

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

like image 131
Sergey Grinev Avatar answered Sep 22 '22 12:09

Sergey Grinev