I am uploading files from swing interface to remote server using loop.Inside loop, application is selecting files sequentially one after another based on size and file is uploading to the server.For every file upload, I want to show the progress bar, using JProgressBar class. I am able to show the progress bar for the first files uploaded, but for the next File uploading I need to reinitialize the ProgressBar again. I am not able to do this.
you need to use thread e.g your progressbar is myProgressbar; int max = total_process; myProgressbar.setMaximum(max); Thread t = new Thread(){ public void run(){ for(int i =0;i<max;i++){ do_process(i); myProgressbar.setValue(i); } } };
Hi Daniel, First of all thanks for ur help but I couldn't understand 'total_process' variable and method 'do_process()'. Can u plz explain it to me.My scenario is my swing application takes the file automatically(which i have done it through loop) from one folder one by one sorting by size where user store all the files they want to upload and i want to show the progress of uploading of all files through JProgressBar. Now my progressbar showing the status of progress of first file only. Regards Bikash [ February 11, 2003: Message edited by: Bikash Paul ]
He's my best friend. Not yours. Mine. You can have this tiny ad:
a bit of art, as a gift, the permaculture playing cards