πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #11075

Re: Beginner question: how can I get a ProgressBar to refresh ?

#11075
From: Matt Krevs
Date: Wed, 14 Jul 1999 00:00
63 lines
2375 bytes
I'm no expert but..

I think the problem is that you are trying to update the progress bar in the
event dispatching thread. Basically the update wont happen until your for
loop finishes.

The way (I think) JProgressBar was meant to be used was to give an update of
the status of a piece of work running within another thread.

eg
open frame
display progress bar
spawn a new thread that does some work

in the new thread...

for loop {
    do some work
    SwingUtlilites.invokeLater ( progressBar.setValue(whatever) )
}

Yannick.Bollati <Yannick.Bollati@wanadoo.fr> wrote in message
news:7mg7fi$t615@forums.borland.com...
> Hakan UNLU a οΏ½crit dans le message <7mg3i1$tm16@forums.borland.com>...
> >Usually valide refreshes a component. Try using
> >
> >progressBar.validate()
> >
> >(I did not check if progressbar has a validate method but it should have)
> >
> >--
> >Hakan UNLU
>
>
> No, this does not seems to work. I have changed my code like this... with
> the same results.
>
> public void run(Frame motherframe)
>   {
>       DisplayProgressDialog dpd = new
>       DisplayProgressDialog(motherframe,"things are going on...",false);
>       dpd.jProgressBar1.setMinimum(0);
>       dpd.jProgressBar1.setMaximum(10);
>       dpd.show();
>       float p=0;
>       for(int i=1;i<=10;i++)
>       {
>         dpd.jProgressBar1.setValue(i);
>
>           // just try to call .validate() on everything....
>         motherframe.validate();
>         dpd.validate();
>         dpd.jProgressBar1.validate();
>
>         for(int j=0;j<10000;j++)
>         {
>             p=p* 1 / ((float) j);
>          }
>       }
>   }
>
>
>
Technical Details
Message-ID: <7mgfqp$18d9@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <7mg1po$t311@forums.borland.com> <7mg3i1$tm16@forums.borland.com> <7mg7fi$t615@forums.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 111d45,3a34dcd158442895
X-Google-Attributes: gid111d45,public
From: "Matt Krevs" <mattkrevs@flex.com.au>
Subject: Re: Beginner question: how can I get a ProgressBar to refresh ?
Date: 1999/07/14
Message-ID: <7mgfqp$18d9@forums.borland.com>
X-Deja-AN: 500702923
References: <7mg1po$t311@forums.borland.com> <7mg3i1$tm16@forums.borland.com> <7mg7fi$t615@forums.borland.com>
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211
Organization: Another Netscape Collabra Server User
X-MSMail-Priority: Normal
Reply-To: "Matt Krevs" <mattkrevs@flex.com.au>
Newsgroups: borland.public.jbuilder.java.swing