How to use the Swing Timer to delay the loading of a progress bar
问题 I need to find a way to use the Swing Timer with a progress bar. I tried using Thread.sleep(), but it crashed the app when I used it. Any ways to use the Swing Timer instead of the Sleep()? public void piiEros(int dist) { Pii pii = new Pii(); pii.setVisible(true); for(int pc = 0;100 > pc; pc++) { try { Thread.sleep(dist/100); } catch (InterruptedException ex) { Logger.getLogger(Trav.class.getName()).log(Level.SEVERE, null, ex); } pii.pg.setValue(pc); } pii.dispose(); o.Eros(); } NOTES: Pii is