Hi every1 i hav a problem with progress bar tht is i hav to progress in a slow motion but its not stopping just reaching 100% very quickly although i use a sleep method.... for(int i=0;i<=100;i+=10){ jProgressBar1.setValue (i); jProgressBar1. Thread.sleep (500); } pls help me out
John Smith
Ranch Hand
Joined: Jul 20, 2001
Posts: 84
posted
0
I'm not sure, but maybe you need to invoke the sleep method on the current thread, i.e. Thread.currentThread().sleep(500).
Ali Hassaan
Ranch Hand
Joined: May 16, 2001
Posts: 103
posted
0
Originally posted by Randy Gordon: I'm not sure, but maybe you need to invoke the sleep method on the current thread, i.e. Thread.currentThread().sleep(500).
Thanx Randy!! I have use Timer class and its working fine. Thanx for ur reply
john klucas
Greenhorn
Joined: Jul 31, 2001
Posts: 23
posted
0
Hi ali, hey can you show me how u r using ur Jprogressbar1. I will appreciate it! JL
Ali Hassaan
Ranch Hand
Joined: May 16, 2001
Posts: 103
posted
0
Originally posted by john klucas: Hi ali, hey can you show me how u r using ur Jprogressbar1. I will appreciate it! JL
Timer timer = new Timer(1000, new ActionListener() { public void actionPerformed(ActionEvent evt) { progressbar.setValue(current+=10); } }); here time is in milliseconds i have start timer on button click event like timer.start(); from tht on progressbar starts working.
john klucas
Greenhorn
Joined: Jul 31, 2001
Posts: 23
posted
0
Hey thanx a lot. I got that stuff working. But how do i clear the progress bar, i mean when i want to upload another file i want that progress bar to go from 0% to 100% again. Right now it only works when i do it first time and it shows 100%. How will reset that. Thanx in advance!
Matt Hansen
Ranch Hand
Joined: Jul 31, 2001
Posts: 34
posted
0
To restart it just set the current value of the progress bar to zero and recreate the timer.