🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: progress bar during a critical operation in the event dispatch thread

#100
From: David C. Browne
Date: Sun, 22 Jan 2006 23:16
47 lines
2099 bytes
Tony wrote:

> Sample code that explains my problem:
> 
> startButton.addActionListener(new Action Listener()
> {
>  public void actionPerformed(ActionEvent e)
>  {
>   method1();
>   method2();
>  }
> }
> );
> 
> method1()
> {
> /*
>   I have some long-running operations in this method.
>   Is it true that there is no way to display and
>   update a progress bar in this method?
> */
> }
> 
> method2()
> {
>   /*
>   This method contains operations that must not
>   be performed until method1 is finished
>   */
> 
> }
> 
> My reasoning:
> 
> 1. Display and updates of the progress bar are UI operations
>     which must take place on a Swing thread.
> 2. Swing thread will not resume until actionPerformed method
>     exits.

In addition to Kevin's comments, you may want to have a look at Foxtrot:

http://foxtrot.sourceforge.net/

It may be a better approach than SwingWorker since it uses a synchronous 
model, which is what you are asking for with method2().

David Browne
Technical Details
Message-ID: <43d411b4$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news4.google.com!newshub.sdsu.edu!pln-w!lotsanews.com!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <43d3363e$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 111d45,dfff19faba996f35
X-Google-Attributes: gid111d45,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Sun, 22 Jan 2006 15:16:50 -0800
From: "David C. Browne" <hyperfatigued-removethispart@comcast.net>
User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923)
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.jbuilder.java.swing
Subject: Re: progress bar during a critical operation in the event dispatch
 thread
References: <43d3363e$1@newsgroups.borland.com>
In-Reply-To: <43d3363e$1@newsgroups.borland.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 24.20.113.84
Message-ID: <43d411b4$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1137971636 24.20.113.84 (22 Jan 2006 15:13:56 -0700)
Lines: 47
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news4.google.com!newshub.sdsu.edu!pln-w!lotsanews.com!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail