title: Refreshing a JLabel
body: <p>I'm trying to display the current time in a <code>JFrame</code>. How can I refresh the text in the <code>JLabel</code> without opening a separate frame each time it has to update? </p>
  
  <p>Here's all of my code so far...</p>
  
  <h2><code>Test</code></h2>
  
  <pre><code>public class Test{
  
      static String timeDisplay = "";
  
      public static class time extends Thread{
          static int timeHours = 7;
          static int timeMins = 30;
          static int timeSecs = 0;
          @Override
          public void run(){
  
              while(true){
                  try{
  
                      time.sleep(1000);
                      timeSecs++;
  
                      if(timeSecs == 60){
                          timeMins++;
                          timeSecs = 0;
                      }
                      if(timeMins == 60){
                          timeHours++;
                          timeMins = 0;
                      }
  
                      if(timeHours &lt; 10){
                          if(timeMins &lt; 10){
                              if(timeSecs &lt; 10){
                                  timeDisplay = "0" + timeHours + ":" + "0" + timeMins + ":" + "0" + timeSecs;
                              }
                              else{
                                  timeDisplay = "0" + timeHours + ":" + "0" + timeMins + ":" + timeSecs;
                              }
                          }
                          else{
                              if(timeSecs &lt; 10){
                                  timeDisplay = "0" + timeHours + ":" + timeMins + ":" + "0" + timeSecs;
                              }
                              else{
                                  timeDisplay = "0" + timeHours + ":" + timeMins + ":" + timeSecs;
                              }
                          }
                      }
                      else{
                          if(timeMins &lt; 10){
                              if(timeSecs &lt; 10){
                                  timeDisplay = timeHours + ":" + "0" + timeMins + ":" + "0" + timeSecs;
                              }
                              else{
                                  timeDisplay = timeHours + ":" + "0" + timeMins + ":" + timeSecs;
                              }
                          }
                          else{
                              if(timeSecs &lt; 10){
                                  timeDisplay = timeHours + ":" + timeMins + ":" + "0" + timeSecs;
                              }
                              else{
                                  timeDisplay = timeHours + ":" + timeMins + ":" + timeSecs;
                              }
                          }
                      }
  
                      System.out.println(timeDisplay);
                      //CountDown time = new CountDown(timeDisplay);
  
  
                  }
                  catch(Exception e){
                      System.out.println("Something went wrong :(");
                  }
              }
  
          }
  
      }
  
      public static void main(String[] args){
  
          time time = new time();
          time.start();
              try {
                  TimeUnit.SECONDS.sleep(1);
                  CountDown window = new CountDown(timeDisplay);
                  window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                  window.setSize(500, 500);
                  window.setVisible(true);
              }
              catch (Exception e) {
                  e.printStackTrace();
              }
  
      }
  
  }
  </code></pre>
  
  <h2><code>CountDown</code></h2>
  
  <pre><code>public class CountDown extends JFrame{
  
      private static final long serialVersionUID = 1L;
  
      static JLabel label = new JLabel();
  
      public CountDown(String time){
  
          super("Title");
          setLayout(new FlowLayout());
  
          add(label);
          label.setText("Current Time: " + time);
  
          Handler eventHandler = new Handler();
  
      }
  
      private class Handler implements ActionListener{
  
          public void actionPerformed(ActionEvent event){
  
              String string = "";
  
              if(event.getSource()==""){
                  string = String.format("label 1: %s", event.getActionCommand());
              }
  
          }
  
      }
  
  }
  </code></pre>
  
  <p>My intentions for this program was to make a frame that displayed the current time. It's using local time from the program, not the actual time. Thanks in advance, and feel free to let me know if I should change anything in my code to make it better. </p>