title: How do you change label text in java after a timer ticks a second passed?
body: <p>I have a timer with a delay of 5 seconds. I am trying to change the label named lblTimer after a second passes to act as a countdown. I am having issues with it as currently it only works at 5 seconds. Do you have any suggestionsuggestions?</p>
  
  <pre><code>protected void Addition() {
      //addition function 
  
      final int delay = 5000; //milliseconds
  
      ActionListener taskPerformer = new ActionListener() {
          @SuppressWarnings("unused")
          public void actionPerformed(ActionEvent evt) {
              //...Perform a task...
              frame.getContentPane().setBackground(Color.red);
          }
      };
  
      new Timer(delay, taskPerformer).start();
      Random RandomNumber = new Random();
      int number1 = RandomNumber.nextInt(12);
      int number2 = RandomNumber.nextInt(12);
      int number3 = RandomNumber.nextInt(12);
      lblAnswer.setText("");
      lblFirstNumber.setText(""+ number1);
      lblfunction1.setText("+");
      lblsecondNumber.setText(""+number2);
      lblfunction2.setText("+");
      lblthirdnumber.setText(""+number3);
      lblequals.setText("=");
      answer = number1+number2+number3;
      if(delay &lt;= 1000){
          lblTimer.setText("1"); 
      }    
      else if(delay == 2000){
          lblTimer.setText("2"); 
      }    
      else if(delay == 3000){
          lblTimer.setText("3"); 
      } 
      else if(delay == 4000){
          lblTimer.setText("4"); 
      }    
      else if (delay == 5000){
          lblTimer.setText("5"); 
      }
  }
  </code></pre>