這裏是一個小一例子:進度條與線程(的Java Swing)
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
int x = 0;
while (jProgressBar1.getValue() < 100) {
try {
Thread.sleep(50);
x++;
jProgressBar1.setValue(x);
jProgressBar1.repaint();
} catch (InterruptedException ex) {
Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);
}
System.out.println(jProgressBar1.getValue());
}
}
System.out.println(jProgressBar1.getValue());
回到位數IDE輸出,但jProgressBar1不畫這個值。這段代碼有什麼問題?請幫忙。
試圖尋找到使用'SwingWorker' – EpicPandaForce 2014-09-03 14:07:55
http://docs.oracle.com/javase/tutorial/uiswing/components/progress.html – 2014-09-03 14:08:21
我提供了一個例子,如何它應該被執行。 – 2014-09-03 14:15:38