I am a beginner in java .So please let me know how can i simultaneously run the progress bar and my application code together.In other words i want to make my progressbar to increment as long as my application code is doing some processing.Please elaborate it with code. What i think is that i have to add two threads simultaneously.One thread updating the progressbar thread but i am not sure whether its the right way or not. i have written this code for incrementing progress bar (hard coded)
class ProgressMonitor implements Runnable {
public void run() {
jProgressBar1.setStringPainted(true);
//run untill 100% complete
while (progress < 100) {
//update the progressbar
jProgressBar1.setValue(++progress);
jProgressBar1.repaint();
try {
//Sleep for .25 second
Thread.sleep(250);
} catch (InterruptedException ex) {
}
}
}