java - Countdown Pause & Resume with Timer -


here have question make me big trouble.. coded countdown competition using java. here interface

enter image description here

i used countdown() method task this..

public void countdown(){         timertask doit = new timertask() {         @override         public void run() {             c_s-=1;             if (c_s == -1)     {       c_m -= 1;       c_s = 59;     }     if (c_m == -1)     {       c_h -= 1;       c_m = 59;     }     hour.settext(c_h+"");     min.settext(c_m+"");     sec.settext(c_s+"");              if((c_h==-1)&& (c_m==59)&& (c_s==59)){                  time_countdown.cancel();                 joptionpane.showmessagedialog(rootpane, "invaild time");                 system.exit(0);             }             if((c_h==0)&& (c_m==0)&& (c_s==0)){                  time_countdown.cancel();                 joptionpane.showmessagedialog(rootpane, "times up");              }           }     };     time_countdown.scheduleatfixedrate(doit, 0l, 1000l); } 

my case how pause , resume time..? have no idea that..!!..if can give me solution using method, easy me.. (do not care round 01 line. stopwatch)

maybe easiest way if pause button toggles bool variable tells run method exit right after being called (before change happens) or go through it.


Comments

Popular posts from this blog

java - Solr query version issue: Invalid version or the data in not in 'javabin' format -

Hard vs. Soft Water: What's The Difference?

The Ten Most Livable Cities In The World