Hello,
i would like to implement my method with javax.swing.timer instead of java.util.timer because i need to be able to stop my timer.
this is my method with java.util.timer:
and i would like to be able to do the same thing with javax.swing.timer but i dont know how to do that, could someone help me?
this method is to implement a working clock into my programm
i would like to implement my method with javax.swing.timer instead of java.util.timer because i need to be able to stop my timer.
this is my method with java.util.timer:
if(event.getSource() == this.random) if (difficulty == "Einfach" || difficulty == "Mittel" || difficulty == "Schwer"){ if (timerzahl == 1){ hours = 0; minutes = 0; seconds = 0; } else{ {TimerTask timerTask = new TimerTask() { DecimalFormat df = new DecimalFormat("00"); @Override public void run() { seconds++; if(seconds > 59){ seconds = 0; minutes++; } if(minutes >59){ minutes = 0; hours++; } uhr.setText(df.format(hours) + ":" + df.format(minutes) + ":" + df.format(seconds)); } }; timer.schedule(timerTask, new Date(), 1000); } } timerzahl = 1; }
and i would like to be able to do the same thing with javax.swing.timer but i dont know how to do that, could someone help me?
this method is to implement a working clock into my programm