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


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

Re: Keeping GUI responsiv

From "John B. Matthews" <john.b..matthews@THRWHITE.remove-dii-this>
Subject Re: Keeping GUI responsiv
Message-ID <nospam-CFB607.11155918072008@aioe.org> (permalink)
Newsgroups comp.lang.java.gui
References <cLydnXdDLaASYOLVnZ2dnUVZ_q2dnZ2d@comcast.com>
Date 2011-04-27 15:46 +0000
Organization TDS.net

Show all headers | 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