JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.util.swing
Class JCSwingWorker

java.lang.Object
  |
  +--com.klg.jclass.util.swing.JCSwingWorker

public abstract class JCSwingWorker
extends Object

An abstract class that you subclass to perform GUI-related work in a dedicated thread. To use this class you override the void implementations of start(), construct(), and finish().

The start() method is called initially and once this has completed, the construct() method is launched in it's own thread. When this thread has completed, the finish() method is called from the Swing thread.

It is guaranteed to be safe to alter GUI components in the start() and finish() methods.

To safely alter Swing components in the construct() method, you must either create a separate Runnable class and use SwingUtilities().invokeLater() on it, use the convienence object RunnableObjectWrapper, or use a thread-safe helper class such as MessageHelper or ProgressHelper.

See Also:
JCSwingRunnable, JCMessageHelper, JCProgressHelper

Constructor Summary
JCSwingWorker()
          Starts a thread that will call the construct method and then exit.
 
Method Summary
abstract  Object construct()
          Computes the value to be returned by the get method.
 void finished()
          Called on the event dispatching thread (not on the worker thread) after the construct method has returned.
 Object get()
          Returns the value created by the construct method.
 void interrupt()
          A new method that interrupts the worker thread.
 void start()
          Called on the event dispatching thread (not on the worker thread) before the construct method is called.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JCSwingWorker

public JCSwingWorker()
Starts a thread that will call the construct method and then exit.

Method Detail

start

public void start()
Called on the event dispatching thread (not on the worker thread) before the construct method is called.


construct

public abstract Object construct()
Computes the value to be returned by the get method.

Returns:

finished

public void finished()
Called on the event dispatching thread (not on the worker thread) after the construct method has returned.


interrupt

public void interrupt()
A new method that interrupts the worker thread. Call this method to force the worker to abort what it's doing.


get

public Object get()
Returns the value created by the construct method.

Returns:
value created by the construct method

Copyright © 2004 Quest Software Inc..
All rights reserved.