Reputation: 2757
Is there a way to hide a stage after a specified time was passed like a few seconds or minutes ?
Upvotes: 3
Views: 1566
Reputation: 29510
A solution with a 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();
Upvotes: 8