JavaFX在2秒后在GridPane上添加行

时间:2018-08-22 17:37:09

标签: java javafx gridpane

给出:

    BorderPane root = new BorderPane();
    GridPane block = new GridPane();
    block.addRow(0, new Text("HELLO"));

    ScheduledExecutorService someScheduler = Executors.newScheduledThreadPool(4);
    someScheduler.schedule(() -> {
        System.out.println("IN");
        block.addRow(1, new Text("WORLD"));
        System.out.println("OUT");
    }, 2, TimeUnit.SECONDS);

    root.setCenter(block);

    Scene scene = new Scene(root, 1280, 720);
    primaryStage.setScene(scene);
    primaryStage.show();

2秒后GridPane是否应该添加一行?输出到达IN,但到达OUT。有人可以向我解释这种行为吗?

1 个答案:

答案 0 :(得分:0)

给我一​​个镜头,我添加了blob

response