I'm trying to add to my program progress bar ,when it executes.Actualy I want to add something like this:
public class TestProgressBar extends javax.swing.JFrame {
public TestProgressBar Bar;
public TestProgressBar() {
initComponents();
Bar=this;
}
public void start(){
//progress bar action
SwingUtilities.invokeLater(new Runnable() {
public void run() {
for(int i=0;i<100;i++){
jProgressBar1.setValue(jProgressBar1.getValue()+10);
try {
Thread.currentThread().sleep(100);
} catch (InterruptedException ex) {
Logger.getLogger(TestProgressBar.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
});
//program running
while(true);
}
public static void main(String args[]) {
TestProgressBar t=new TestProgressBar();
t.setSize(320, 320);
t.pack();
t.setVisible(true);
t.start();
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JProgressBar jProgressBar1;
// End of variables declaration
}
but it doesn't work
I found code that implements what i want to do
Code
but for met it's messy
So the questrion is how to implement progress bar which changes than program is working?
The progress bar value changes but form doesn't show these changes