Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #3789

Re: Keeping GUI responsiv

Path csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!news.glorb.com!news-out.readnews.com!news-xxxfer.readnews.com!news-out.news.tds.net!newsreading01.news.tds.net!86597e80!not-for-mail
From "John B. Matthews" <john.b..matthews@THRWHITE.remove-dii-this>
Subject Re: Keeping GUI responsiv
Message-ID <nospam-CFB607.11155918072008@aioe.org> (permalink)
X-Comment-To comp.lang.java.gui
Newsgroups comp.lang.java.gui
In-Reply-To <cLydnXdDLaASYOLVnZ2dnUVZ_q2dnZ2d@comcast.com>
References <cLydnXdDLaASYOLVnZ2dnUVZ_q2dnZ2d@comcast.com>
Content-Type text/plain; charset=IBM437
Content-Transfer-Encoding 8bit
X-Gateway time.synchro.net [Synchronet 3.15a-Win32 NewsLink 1.92]
Lines 45
Date Wed, 27 Apr 2011 15:46:56 GMT
NNTP-Posting-Host 96.60.20.240
X-Complaints-To news@tds.net
X-Trace newsreading01.news.tds.net 1303919216 96.60.20.240 (Wed, 27 Apr 2011 10:46:56 CDT)
NNTP-Posting-Date Wed, 27 Apr 2011 10:46:56 CDT
Organization TDS.net
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.gui:3789

Show key headers only | View raw


  To: comp.lang.java.gui
In article <cLydnXdDLaASYOLVnZ2dnUVZ_q2dnZ2d@comcast.com>,
 Lew <com.lewscanon@lew> wrote:

> Alex wrote:
> >> I do some lengthy calculations in the event handling thread and
> >> therefore my GUI is not responsive.
> >> I know I could run the calculations in a worker thread, but I wonder
> >> if there is not a simpler way.
> >>
> >> In C++ with the Qt class library there is a 'processEvents()' methods
> >> that can be called from the event handling thread to process pending
> >> (GUI) events. Is there something equivalent in Java or do I absolutely
> >> need a worker thread?
> 
> Knute Johnson wrote:
> > Yes.
> 
> <http://java.sun.com/javase/6/docs/api/javax/swing/SwingWorker.html>
> 
> Read the Swing tutorial.  It covers the need to do all GUI work, even 
> construction, on the Event Dispatch Thread (EDT), the GUI thread.
> 
> Don't try to wiggle out of this.  It is a curiosity to me that some people 
> look for a "way out" of having to put work not on the EDT and GUI only on the 
> EDT.  That's the way it works.  Just do it right, and things work.  What's 
> there to get "out" of?  How is it not simple enough the way it is?
> 
> Just learn the right way.

OP: Having travelled this road recently, it's clear that you wind up 
doing _more_ work if you try to avoid SwingWorker: EDT, synchronization, 
etc. Here's a back port if you're stuck on a pre-1.6 system:

<https://swingworker.dev.java.net/>

-- 
John B. Matthews
trashgod at gmail dot com
home dot woh dot rr dot com slash jbmatthews

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

Back to comp.lang.java.gui | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Re: Keeping GUI responsiv "Lew" <lew@THRWHITE.remove-dii-this> - 2011-04-27 15:46 +0000
  Re: Keeping GUI responsiv "John B. Matthews" <john.b..matthews@THRWHITE.remove-dii-this> - 2011-04-27 15:46 +0000

csiph-web