🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.language
2 messages
2 total messages Started by Salvador Huertas Fri, 16 Sep 2005 09:54
Update jLabel
#444
Author: Salvador Huertas
Date: Fri, 16 Sep 2005 09:54
9 lines
1090 bytes
Hi friends,

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.

Thanks in advance!!
Salvador Huertas.
Re: Update jLabel
#445
Author: 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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads