title: how to put a timer on a JLabel to update itself every second
body: <p>I created a game and in my swing GUI interface I want to put a timer. The way I do this at the moment is have a field with the current time , gotten with <code>System.currentTimeMillis()</code> which gets it's value when the game starts .In the method of my game i put the   <code>System.currentTimeMillis()</code>- field; and it tells you the current time passed since the game started.</p>
  <p>Nevertheless, how do get this  to update itself every second lets say, so the <code>JLabel</code> will have : timePassed: 0s , timePassed: 1s and so on. Have in mind that i don't use threads in my game at any point.</p>
  <p>EDIT: thank you all for your kind suggestions. I used a combination of your answers please give me some feedback.</p>
  <p>I have the JLabel as a field called time. (else i cant handle it).</p>
  <pre><code>time = new JLabel(&quot;Time Passed:  &quot; + timePassed() + &quot; sec&quot;);
  panel_4.add(time);
  
  ActionListener actionListener = new ActionListener() {
      public void actionPerformed(ActionEvent actionEvent) {
          time.setText(&quot;Time Passed: &quot; + timePassed() + &quot; sec&quot;);
      }
  };
  
  Timer timer = new Timer(1000, actionListener);
  timer.start();
  </code></pre>