Article View: borland.public.jbuilder.java.api
Article #1981Re: Freeze the screen
From: Ant�nio Ferreira
Date: Mon, 18 Jun 2001 18:01
Date: Mon, 18 Jun 2001 18:01
62 lines
2780 bytes
2780 bytes
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:
<3b2e4163_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!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnewsReferences:
<3b27452c_1@dnews> <3b29bd14$1_1@dnews> <3b2dd800_1@dnews> <3b2de3a8$1_2@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-18 11:05:44 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> Subject: Re: Freeze the screen Date: Mon, 18 Jun 2001 19:01:10 +0100 Lines: 64 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: <3b2e4163_1@dnews> X-Trace: dnews 992887139 195.22.4.113 (18 Jun 2001 10:58:59 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!nntp-relay.ihug.net!ihug.co.nz!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!dnews