How to start and stop a timer in Java
<p>I am not very good at Java...</p>

<p>I am working on a stopwatch, with a start, stop and reset button. </p>

<p>When u press start, it obviously starts. When u press stop, it pauses( using <code>timer.cancel();</code>). When u press reset it makes all the values 0, and stops. and when u press start again, it should continue to count, where it was stopped(unless it was reset).</p>

<p>I am using a <code>java.util.timer;</code>
So here  is the question:
How do you start a timer, that was paused(canceled)? For example, if I used the stop button to stop it. And in my code it would look like this: <code>timer.cancel();</code>, how can I start it again??</p>

<p>I know that you can do this using <code>timer.stop()</code> and <code>timer.start()</code> in <code>vb</code></p>

<pre><code> import java.util.Timer;
 import java.util.TimerTask;

public static void timerStart()
{

        //timer
        if(running == false)
        {

            TimerTask task = new TimerTask()
            { 


                public void run()
                {
                    //what to do at each excecution
                    seconds++;
                    lbl.setText(Short.toString(seconds));
                }
            };

        timer.scheduleAtFixedRate(task,1000,1000);
        }
        running = true;
}
</code></pre>

<p>and </p>

<pre><code> public static void timerStop()
 {
    timer.cancel();
    runnig = false;
 }
</code></pre>