Flashing label in javafx gui

前端 未结 2 1791
情歌与酒
情歌与酒 2020-12-19 18:58

I\'m looking to make a label blink in and out ever 0.1 seconds in javafx. The text appears on top of an ImageView gif that is running in the background. How would I go about

2条回答
  •  暖寄归人
    2020-12-19 19:35

    Use a timeline:

    Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(0.05), evt -> label.setVisible(false)),
                                     new KeyFrame(Duration.seconds( 0.1), evt -> label.setVisible(true)));
    timeline.setCycleCount(Animation.INDEFINITE);
    timeline.play();
    

提交回复
热议问题