title: Stopwatch in java
body: <p>Im trying to make a stopwatch in java, that looks like so 00:00:00, which starts counting once a button is pressed. For some reason it won't work but I'm sure there is something that I am missing.</p>
  
  <pre><code>for (;;)
      {
      if (pause == false)
              {
                 sec++; 
  
                 if (sec == 60)
                 {
                     sec = 0;
                     mins++;
                 }
                     if (mins == 60)
                     {
                         mins = 0;
                         hrs++;
                     }
  
                 String seconds = Integer.toString(sec);
                 String minutes = Integer.toString(mins);
                 String hours = Integer.toString(hrs);
  
                 if (sec &lt;= 9)
                 {
                     seconds = "0" + Integer.toString(sec);
                 }
                 if (mins &lt;= 9)
                 {
                     minutes = "0" + Integer.toString(mins);
                 }
                 if (hrs &lt;= 9)
                 {
                     hours = "0" + Integer.toString(hrs);
                 }
  
                 jLabel3.setText(hours + ":" + minutes + ":" + seconds);
              }
  </code></pre>