How to use PauseTransition method in JavaFX?

前端 未结 2 766
别那么骄傲
别那么骄傲 2020-12-06 14:26

I read the book, but I am still confused about pause transition methods. I made a label showing number, and I want that number to be increased in every second.

2条回答
  •  春和景丽
    2020-12-06 14:45

    As commented by Adowarth :

    you can use the PauseTransition if you start it again inside of the finish handler

    int cycle = 0;
    label.setText("Started");
    PauseTransition pause = new PauseTransition(Duration.seconds(1));
    pause.setOnFinished(event ->
       label.setText("Finished cycle " + cycle++);
       pause.play(); 
    );
    pause.play(); 
    

提交回复
热议问题