用netbeans写了一个简单的窗口,只有一个按钮和一个进度条,我想实现点击按钮,然后让进度条一点点往前跑
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
jProgressBar1.setMaximum(2000000);
jProgressBar1.setMinimum(0);
for (int i = 0; i < 2000000; i++) {
try {
Thread.sleep(1);
jProgressBar1.setValue(i);
}
catch (InterruptedException ex) {
Logger.getLogger(DesktopApplication1View.class.getName()).log(Level.SEVERE, null, ex);
}
}