🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.api
Article #1982

Re: Freeze the screen

#1982
From: Ant�nio Ferreira
Date: Tue, 19 Jun 2001 08:28
77 lines
3191 bytes
Hi,

  I did it! To make it work I just put the refresh thread inside the worker
thread. Not like it is in the code below. Thank you for all your help,

  Ant�nio Jos� Ferreira

"Ant�nio Ferreira" <antonio.ferreira@artesis.co.pt> wrote in message
news:3b2e4163_1@dnews...
> Greetings,
>
>   I tried a simpler example without a progress bar and with a message
status
> frame but it still didn't   work. Watch the code below:
>
>     if (this.finishedThread) {
>       this.finishedThread = false;
>       this.alreadyDone = false;
>       final DialogMenssage dm = new DialogMessage("Warning", "Refreshing
> cards...", 90, 30);
>
>
>       final SwingWorker worker = new SwingWorker() {
>         public Object construct() {
>           dm.show();
>           alreadyFinished=true;
>           return null;
>         }
>       };
>       worker.start();
>
>       while (!alreadyFinished) {};
>       Runnable refresh = new Runnable() {
>         public void run() {
>           refreshScreenThread();
>           dm.dispose();
>         }
>       };
>
>       SwingUtilities.invokeLater(refresh);
>     }
>
> What else is wrong?
>
>   Ant�nio Jos� Ferreira
>
> "Torsten Welches" <torsten.welches@who.cares.netcologne.de> wrote in
message
> news:3b2de3a8$1_2@dnews...
> >
> > "Ant�nio Ferreira" <antonio.ferreira@artesis.co.pt> wrote:
> > >      final ProgressBar1 bp = new
> >
>ProgressBar1(0,97+(this.jTabbedPaneCartas.getComponentCount()>*8),"Cards
> actualization");
> > >      bp.show();
> > >      final SwingWorker worker = new SwingWorker() {
> > >          public Object construct() {
> > >              refreshCardsThread(bp);
> > >              return null;
> > >          }
> > >      };
> > >      worker.start();
> >
> > you are refreshing the ProgressBar on the SwingWorker's
> > background thread - SwingWorker.construct is running on it's
> > own thread. You are not "allowed" to do that, you rather have
> > to run all ui-relevant stuff on the event dispatch thread.
> >
http://java.sun.com/docs/books/tutorial/uiswing/overview/threads.html#rule
> >
> > The article shows how to use SwingUtilities.invokeLater to
> > ensure this.
> >
> > Torsten
>
>
Technical Details
Message-ID: <3b2f0cac$1_1@dnews>
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!nntp-relay.ihug.net!ihug.co.nz!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnews
References: <3b27452c_1@dnews> <3b29bd14$1_1@dnews> <3b2dd800_1@dnews> <3b2de3a8$1_2@dnews> <3b2e4163_1@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 1089d0,18c80611e0e8e298
X-Google-Attributes: gid1089d0,public
X-Google-ArrivalTime: 2001-06-19 01:39:55 PST
From: "Ant�nio Ferreira" <antonio.ferreira@artesis.co.pt>
Newsgroups: borland.public.jbuilder.java.api
References:  <3b27452c_1@dnews>  <3b29bd14$1_1@dnews>  <3b2dd800_1@dnews>  <3b2de3a8$1_2@dnews> <3b2e4163_1@dnews>
Subject: Re: Freeze the screen
Date: Tue, 19 Jun 2001 09:28:41 +0100
Lines: 79
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2919.6600
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600
NNTP-Posting-Host: 195.22.4.113
Message-ID: <3b2f0cac$1_1@dnews>
X-Trace: dnews 992939180 195.22.4.113 (19 Jun 2001 01:26:20 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!nntp-relay.ihug.net!ihug.co.nz!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!dnews