🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: To thread or not to thread?

#9794
From: Ken Sprague
Date: Sat, 29 Jan 2000 00:00
44 lines
1895 bytes
Brain,

The button listeners are invoked by the GUI thread, so any lengthy
actions performed by them slow down other GUI actions, like
repainting.  You can use:

    SwingUtilities.invokeLater() or SwingUtilities.invokeAndWait()

or

    EventQueue.invokeLater() or EventQueue.invokeAndWait()     // Java
2

from within the event listeners to set up some code to be run on the
main thread.  Hope this helps.

Ken


BS <bsue@ican.net> wrote in message
news:85oo41$9ov24@bornews.borland.com...
> I'm writing an app that is using a series of panels.  Each panel
contains a
> set of buttons, etc...  When a certain button is pressed the current
panel
> is set invisible while the next one is set visible.
>
> My problem is:  When I click on a button it seems that the actions
(ie.
> connect to a database) are taking over resources and the repaint
message is
> delayed causing certain items from the previous panel to be seen
along with
> buttons on the next panel while the action is being performed.
>
> My question is:  Should the actions that are to be performed be run
in a
> separate thread or is there a function similar to Delphi's
> Application.ProcessMessages()?
>
> Thanks in advance,
> Brian.
>
>
Technical Details
Message-ID: <86v7qc$32m7@bornews.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <85oo41$9ov24@bornews.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,e10483a2298b307b
X-Google-Attributes: gid111d45,public
From: "Ken Sprague" <ksprague@email.msn.com>
Subject: Re: To thread or not to thread?
Date: 2000/01/29
Message-ID: <86v7qc$32m7@bornews.borland.com>
X-Deja-AN: 579216734
Content-Transfer-Encoding: 7bit
References: <85oo41$9ov24@bornews.borland.com>
Organization: Another Netscape Collabra Server User
X-MSMail-Priority: Normal
X-Priority: 3
Content-Type: text/plain; charset="iso-8859-1"
Mime-Version: 1.0
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200
Newsgroups: borland.public.jbuilder.java.swing