I am using progress bar in my application where i am downloading content from a webaite and saving it into my database. I have put a progress bar to indicate if the download is completed but the problem is when everything is saved in my database then the progress bar becomes 100%. While downloading it should be like 5%,10%,25% and so on then after all is saved it will become 100%. How will i do this? sample code that i have written
timer = new Timer(interval, new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if (j ==100){
//a beep is heard when download is completed
Toolkit.getDefaultToolkit().beep();
timer.stop();
jButton3.setEnabled(true);
pb.setValue(0);
String str = "<html>" + "<font color=\"#FF0000\">" + "<b>" + "Downloading completed." + "</b>" + "</font>" + "</html>";
lbldownload.setText(str);
}
j = j + 1;
pb.setValue(j);
}
});
jButton3.setEnabled(false);
j = 0;
String str = "<html>" + "<font color=\"#008000\">" + "<b>" + "Downloading is in progress......." + "</b>" + "</font>" + "</html>";
lbldownload.setText(str);
timer.start();
}