Javafx-2 – is there any way to hide the stage after a certain time?

Is there any way to hide a stage a few seconds or minutes after the specified time?

Solution

Solutions using 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();
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>