3

有没有办法在指定的时间过去后隐藏一个阶段,比如几秒钟或几分钟?

4

1 回答 1

7

带有Timeline的解决方案:

final Stage stage = new Stage();
stage.setScene(new Scene(new Label("Hello")));
stage.show();
Timeline timeline = new Timeline();
timeline.getKeyFrames().add(new KeyFrame(Duration.seconds(10),
    new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent event) {
            stage.hide();
        }
    }));
timeline.play();
于 2013-09-13T08:59:59.090 回答