java - how to stop the timer -


I am using Netbeans 8.0, and it is difficult to stop timer in my GUI. This is my code.

  Public class Task1 implements Runnable {public void run () {long start = System.currentTimeMillis (); While (Thread.interrupted ()) {long time = System.currentTimeMillis () - start up; Last long seconds = time / 1000; Last long minutes = seconds / 60; Last remaining balance = seconds = seconds% 60; Last long hour = minutes / 60; SwingUtilities.invokeLater (New Runnabal) (Public Zero Run) {jLabel3.setText ("Time has passed:" + + + ":" + min + ":" + SEC SEC;)}}}); Try {Thread.sleep (100); } Hold (exception e) {}}}} thread t 1 = new thread (new function 1 ()); Private Zero jButton1ActionPerformed (java.awt.event.ActionEvent evt) {t1.start (); } Private Zero jButton2ActionPerformed (java.awt.event.ActionEvent evt) {t1.interrupt (); // it does not close my timer}  

I made two buttons that starts the jButton1 timer and prevents jButton2 timer. Please advise.


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

c# - NewtonSoft JArray - how to select multiple elements with LINQ -

javascript - amcharts makechart not working -