有没有办法在指定的时间过去几秒钟或几分钟后隐藏一个舞台?
答案 0 :(得分: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();