🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #445

Re: Update jLabel

#445
From: Kevin Dean [TeamB]
Date: Fri, 16 Sep 2005 11:39
37 lines
2475 bytes
Salvador Huertas wrote:

>I have a rutine that shows text (changing text) in a jLabel while the 
>rutine
>is running. My problem is that only show the last text, the java is no
>refreshing this label while the rutine is working. I try jLabel1.repaint(),
>but not works.

Java doesn't have an equivalent to the Windows mechanism to force repaints 
while a process is running.  To accomplish this, you need to look at 
multi-threading:

1) Start a background thread to do the work.
2) At various points in the process, post an event to the AWT event queue 
to update the label with the current status.
3) Write an event handler to handle the "update status" event.

The repaint will then happen automatically.

The beauty of this is that you can then do things like add a "Cancel" 
button to interrupt the process.  However, you should be aware that all 
other AWT event functionality will still be available (e.g. menu 
selection, button clicks) so your best bet would be to pop up a modal 
dialog that the user can't dismiss until the process is complete.

-- 
Kevin Dean [TeamB]
Dolphin Data Development Ltd.
http://www.datadevelopment.com/

NEW WHITEPAPERS
Team Development with JBuilder and Borland Enterprise Server
Securing Borland Enterprise Server
http://www.datadevelopment.com/papers/index.html

Please see Borland's newsgroup guidelines at
http://info.borland.com/newsgroups/guide.html
Technical Details
Message-ID: <xn0e7b1ux216t5001-kdean@www.teamb.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <432a94e8$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: f74b3,f0e81fde785038bb
X-Google-Attributes: gidf74b3,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Kevin Dean [TeamB]" <NkOdSePaAnM@datadevelopment.com>
Subject: Re: Update jLabel
Newsgroups: borland.public.jbuilder.java.language
References:  <432a94e8$1@newsgroups.borland.com>
Organization: Dolphin Data Development Ltd.
User-Agent: XanaNews/1.17.6.2
X-Face: ":yn4zt^A_dn>6~{YJmu^B\'4w)e:apPM\VC=Dvf&*tASxX9|BYczkFd$xr.$vNSZ[3Uobrp]c4\+\l){!WQI.$]veP({HLd;CDYH?iN
Message-ID: <xn0e7b1ux216t5001-kdean@www.teamb.com>
X-Ref: newsgroups.borland.com ~XNS:00000312
MIME-Version: 1.0
Content-Type: text/plain; format=flowed
NNTP-Posting-Host: 70.27.188.248
Date: 16 Sep 2005 04:39:52 -0700
X-Trace: newsgroups.borland.com 1126870792 70.27.188.248 (16 Sep 2005 04:39:52 -0700)
Lines: 37
X-Authenticated-User: kdean
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail