1

ボタンをクリックした後、現在の時刻に基づいてタイマーをリセットしようとしましたが、うまくいきません。

private long startTime  = System.currentTimeMillis();
Timer timer  = new Timer(1000, this);
timer.start();

timer.stop();
long endTime    = System.currentTimeMillis();
long timeInMilliseconds = (endTime - startTime);

timer.reset();
4

2 に答える 2

2

私のプログラムの解決策。みんな、ありがとう。

   public class mainClass {
        private long startTime  = System.currentTimeMillis();
        Timer timer  = new Timer(1000, this);
        .....
    }

    public mainClass {
        timer.start();
    }

    //Everytime the button stop clicked, the time will stop and reset to the most current time of the system
    public actionPerformed () {
        timer.stop();
        long endTime    = System.currentTimeMillis();
        long timeInMilliseconds = (endTime - startTime);

        **startTime  = System.currentTimeMillis();** ACCEPTED
    }
于 2009-03-22T19:23:29.820 に答える