Article View: borland.public.jbuilder.java.api
Article #697Re: Problem with JProgressBar
From: Owen Green
Date: Thu, 20 Feb 2003 17:19
Date: Thu, 20 Feb 2003 17:19
37 lines
2467 bytes
2467 bytes
"Nenko Ivanov" <nivanov@icygen.com> wrote in message news:3e550986@newsgroups.borland.com... > Hi everyone, > I want to create an task status indicator with JProgressBar. > I made one extended JDialog classs with a JProgressBar in it and when my > task starts I show this Dialog and tell the JPorgressBar to change it's > value to the desired one. > Everything seemed to be OK, but the dialog show's up when my task is > finished and it does't make sence ;) > (The task is creating a big HTML file from known amount of data) > So I am not very aquainted with Threads but I think that the answer is > somewhere there. > Can anyone help me find the answer? Sounds like you do ineed need to be running your task in a seperate thread. This will also mean that you need to take care with calls to GUI elements, as these can louse things up if done from other threads - SwingUtilities.invoke() and invokeAndWait() are nesscesary to safely update widgets from threads other than the AWT event thread. There are a number of approches you could take, but an example could involve 1)Define a class that represents your task (either with the threading built in, or not (I'd go for not). 2)Define a listener interface for your task (and the approptiate code in your task class). 3)Implement an instance of this listener and put the GUI updates in there. -- hth Owen
Technical Details
Message-ID:
<3e550e87@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!news1.dtag.de!RRZ.Uni-Koeln.DE!nntp.cs.uni-magdeburg.de!PeerFeed.KWeb.on.ca!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mailReferences:
<3e550986@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1089d0,147e7be8c5b83fd X-Google-Attributes: gid1089d0,public X-Google-ArrivalTime: 2003-02-20 09:34:05 PST From: "Owen Green" <owen@begonefoulmachine.kennulz.demon.co.uk> Newsgroups: borland.public.jbuilder.java.api References: <3e550986@newsgroups.borland.com> Subject: Re: Problem with JProgressBar Date: Thu, 20 Feb 2003 17:19:30 -0000 Lines: 45 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 NNTP-Posting-Host: 62.253.133.169 Message-ID: <3e550e87@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1045761671 62.253.133.169 (20 Feb 2003 09:21:11 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!news1.dtag.de!RRZ.Uni-Koeln.DE!nntp.cs.uni-magdeburg.de!PeerFeed.KWeb.on.ca!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail