File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT / JFace and the fly likes JProgressBar Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT / JFace
Reply Bookmark "JProgressBar" Watch "JProgressBar" New topic
Author

JProgressBar

Ali Hassaan
Ranch Hand

Joined: May 16, 2001
Posts: 103
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
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
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
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
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
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
To restart it just set the current value of the progress bar to zero and recreate the timer.
 
 
subject: JProgressBar
 
Threads others viewed
simple math operation for a progress bar
getting top 10 rows
initialization order
XMLTYPE DATATYPE
Cancelling a progress bar
MyEclipse, The Clear Choice