com.denova.ui
Class Swinger

java.lang.Object
  |
  +--com.denova.ui.Swinger

public abstract class Swinger
extends java.lang.Object

Swinger allows a program, in a thread safe way, to give the user feedback, do work in the background, and then give the user more feedback. It daisy chains 2 SwingWorkers to accomplish this. To use this class:

  1. Create a subclass with a swingBefore(), workInBackground() and a swingAfter() method.
  2. In swingBefore() you can update Swing components because it's run on the EDT. You should not do anything that takes long.
  3. In workInBackground() you do whatever may take a long time, but no Swing access.
  4. In swingAfter() you can update Swing components again.
  5. Instantiate your Swinger. Launch it with execute().
Last modified: 2008.04.04


Constructor Summary
Swinger()
           
 
Method Summary
 void execute()
          Start a thread that will call the swingBefore, workInBackground, swingAfter methods and then exit.
 java.lang.Throwable getLastError()
          Gets the last error, if there was one.
 boolean isDone()
          Determines if done() is finished.
 boolean isError()
          Determines if there was an untrapped throwable error.
 void swingAfter()
          Called on the event dispatching thread (not on the worker thread) after the workInBackground method has returned.
 void swingBefore()
          Called on the event dispatching thread (not on the worker thread) before the workInBackground method has returned.
 void workInBackground()
          Do time consuming non-Swing work in background.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Swinger

public Swinger()
Method Detail

swingBefore

public void swingBefore()
Called on the event dispatching thread (not on the worker thread) before the workInBackground method has returned. You can access Swing in this method. Do not do anything that takes more than a very short time.


workInBackground

public void workInBackground()
Do time consuming non-Swing work in background. Do not access Swing from this method unless the Swing method is documented in its javadocs as thread safe. This method is called on this thread.


swingAfter

public void swingAfter()
Called on the event dispatching thread (not on the worker thread) after the workInBackground method has returned. You can access Swing in this method. Do not do anything that takes more than a very short time.


execute

public void execute()
Start a thread that will call the swingBefore, workInBackground, swingAfter methods and then exit.


isDone

public boolean isDone()
Determines if done() is finished.

Returns:
true if done() is finished.

isError

public boolean isError()
Determines if there was an untrapped throwable error.

Returns:
true if any throwable errors ocurred.

getLastError

public java.lang.Throwable getLastError()
Gets the last error, if there was one.

Returns:
true the last error or null if there wasn't one.