問題、タイマーを実行できるのは1回だけです。関数timer2.cancel()を呼び出したので、それを知っています。およびtimer1.cancel(); ::「これを二度と実行しない」であることをキャンセルします。実際にタイマーを停止する交換機能が必要ですが、スケジュールを変更すると再開できます。どうすればそれを行うことができますか?
public void actionPerformed (ActionEvent e){
if (e.getSource()==jbtStart)
{
System.out.println("Start is pressed");
timer2.cancel();
timer1.schedule(new Task(), 0, delay);
}
else if (e.getSource()==jbtStop)
{
System.out.println("Stop is pressed");
timer1.cancel();
timer2.schedule(new Task2(), 0, delay);
}