title: Trouble implementing a countdown timer in JavaFx
body: <p>I was playing around with JavaFx's animation Framework to build a timer that would countdown from 25 minutes.</p>
  
  <p>Right now my code does countdown from 25 minutes but does not update or animate the Label every second. This is what I have tried so far:</p>
  
  <p>This is the event Handler that begins the countdown when the button is clicked</p>
  
  <pre><code>public class CountdownActionEvent implements EventHandler&lt;ActionEvent&gt; {
  
  private Timer defaultTime;
  private Label timer;
  private Timeline animation;
  private int minutes;
  private int seconds;
  
  public CountdownActionEvent(Timer timer, Label label) {
      this.defaultTime = timer;
      this.timer = label;
  }
  
  private void CountDown() {
  
      for (this.minutes = 25; minutes &gt;= 0; minutes--) {
          for (this.seconds = 59; seconds &gt;= 0; seconds--) {
              this.defaultTime.setMinutes(minutes);
              this.defaultTime.setSeconds(seconds);
              timer.setText(defaultTime.toString());
          }
      }
  
  }
  
  @Override
  public void handle(ActionEvent event) {
      // TODO Auto-generated method stub
  
      animation = new Timeline(new KeyFrame(Duration.seconds(1), e -&gt; CountDown()));
      animation.setCycleCount(Timeline.INDEFINITE);
      animation.play();
  
  }
  }
  </code></pre>
  
  <p>Also This is the Timer class that is assigned to the "defaultTime" object:</p>
  
  <pre><code>public class Timer {
  
  private String minutes;
  private String seconds;
  
  public Timer() {
      this.minutes = "25";
      this.seconds = "00";
  }
  
  public String getMinutes() {
      return this.minutes;
  }
  
  public String getSeconds() {
      return this.seconds;
  }
  
  public void setMinutes(int min) {
      if (min &lt; 10) {
          this.minutes = "0" + min;
      } else {
          this.minutes = min + "";
      }
  }
  
  public void setSeconds(int sec) {
      if (sec &lt; 10) {
          this.seconds = "0" + sec;
      } else {
          this.seconds = sec + "";
      }
  }
  
  public String toString() {
      return this.minutes + ":" + this.seconds;
  }
  
  }
  </code></pre>
  
  <p>when I run this program, the Label "timer" instantly updates to 0 upon pressing the button. I have tried to look for a possible solution but cant seem to fix this issue. Any help is appreciated. Thanks!</p>