Article View: borland.public.jbuilder.java.swing
Article #1292Re: GUI Responsiveness Problem
From: pNichols
Date: Sat, 27 Dec 2003 03:48
Date: Sat, 27 Dec 2003 03:48
36 lines
2773 bytes
2773 bytes
Steve wrote: > Imagine a GUI control that starts a long-running process from its action > event. Since the event handler executes on the event-handling thread, the > GUI is frozen while the process completes. Often this is exactly what we > want (e.g., refreshing a query; there's nothing for the user to do until > the refresh is complete). JButton handles this nicely by depressing and > changing the cursor _before_ the action event handler is called so that > the user knows the application isn't frozen. But JComboBox leaves its > picklist extended and appears frozen to the user until the event handler > exits. > > What I'd like to be able to do is for the JComboBox to get ahold of > itself, but still block on the event-handling thread after that. Any > ideas? > > I came up with a really hideous hack that I'm not happy with: In the > action event handler, create a SwingWorker with an empty construct() > method and the long-running process called from the finished() method > (forcing it on to the event-dispatching thread). The start() method is > called just before the event handler exits. This gives the GUI enough time > to retract the picklist. However this is a kludge because it's timing > dependent. It also doesn't work if you put any other GUI code in the event > handler (e.g., setting the wait cursor) unless you add a delay timer to > the construct method. There's gotta be an easier way to do something so > basic. > > Any ideas greatly appreciated. Thx. > > -Steve there was a good article this month In Java Developer's Journal about Swing and Listener events performance probems that you might want to take a look at. I think it could address some of your issues. www.sys-con.com Look at the bottom article, Swing,Threads, and events
Technical Details
Message-ID:
<3fecff09$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!news-out.visi.com!petbe.visi.com!news.linkpendium.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<3fea3050$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,f4eeb7806688d1cc X-Google-Attributes: gid111d45,public X-Google-ArrivalTime: 2003-12-26 19:46:56 PST Message-ID: <3fecff09$1@newsgroups.borland.com> From: pNichols <paul@computer-logic.net> Subject: Re: GUI Responsiveness Problem Newsgroups: borland.public.jbuilder.java.swing Reply-To: paul@computer-logic.net Date: Fri, 26 Dec 2003 22:48:16 -0500 References: <3fea3050$1@newsgroups.borland.com> Lines: 38 Organization: Computer Logic User-Agent: KNode/0.7.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit NNTP-Posting-Host: 68.71.188.25 X-Trace: newsgroups.borland.com 1072496394 68.71.188.25 (26 Dec 2003 19:39:54 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!news-out.visi.com!petbe.visi.com!news.linkpendium.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail