java - How to use swing timer for sleep in for loop? -


how use swing timer sleep in loop?

for (int j = 0; j < 0; i++) { system.out.println(j); try { thread.sleep(1000); } catch (exception e) { // } }

i think question receiving negative votes because:

  • it unclear context of problem and/or trying
  • you have not listed you've tried before posting
  • google answer question

but in spirit of helpfulness:

i consulted google find resource on java swing timer: http://supportweb.cs.bham.ac.uk/documentation/java/tutorial/uiswing/misc/timer.html

i not java expert, suggest trying:

for (int j = 0; j < 0; i++) {   system.out.println(j);   timer = new timer(one_second, new actionlistener() {      public void actionperformed(actionevent evt) {            //...whatever trying (ie. update progress bar)               if (/* waiting */) {                     try {                         thread.sleep(1000);                         } catch (exception e) {                      //                     }               }          }          });   } 

Comments