JavaFX wait for render

时间:2019-04-08 13:10:44

标签: java javafx-8

I have a simple problem that I'am unable to resolve. If I run this example at the time of printing "AFTER" Scene is not rendered, only empty Stage. If I do runLater the sequence is in order - scene is rendered before "AFTER LATER". How can I wait in code for render (Quantum Toolkit) to complete?

public final void start(final Stage primaryStage)
{
            Button btn = new Button("Hello World!");

            StackPane root = new StackPane();
            root.getChildren().add(btn);

            primaryStage.setScene(new Scene(root, 300, 250));
            primaryStage.show();

            // TODO - wait for render?

            System.out.println("AFTER");

            Platform.runLater(() -> System.out.println("AFTER LATER"));
}

enter image description here

0 个答案:

没有答案