org.jext.misc
Class SwingWorker

java.lang.Object
  extended byorg.jext.misc.SwingWorker
Direct Known Subclasses:
CopyThread

public abstract class SwingWorker
extends java.lang.Object

This class comes from the SwingWorker class described at the URL below(3rd version), but has substantially changed; http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html


Field Summary
protected  HandlingRunnable notifier
           
 
Constructor Summary
SwingWorker(HandlingRunnable notifier)
          Create a thread that will call the work method and then run
 
Method Summary
 void finished()
          Called on the event dispatching thread (not on the worker thread) after the work method has returned.
 java.lang.Object get()
          Return the value created by the work method.
 java.lang.Throwable getException()
          Get the value produced by the worker thread, or null if it hasn't been constructed yet.
 java.lang.Object getValue()
          Get the value produced by the worker thread, or null if it hasn't been constructed yet.
 void interrupt()
          A new method that interrupts the worker thread.
 java.lang.Object run()
          Run the work in the calling thread, and then the notifier callback.
 void start()
          Start the worker thread.
abstract  java.lang.Object work()
          Compute the value to be returned by the get method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

notifier

protected HandlingRunnable notifier
Constructor Detail

SwingWorker

public SwingWorker(HandlingRunnable notifier)
Create a thread that will call the work method and then run

Method Detail

getValue

public java.lang.Object getValue()
Get the value produced by the worker thread, or null if it hasn't been constructed yet.


getException

public java.lang.Throwable getException()
Get the value produced by the worker thread, or null if it hasn't been constructed yet.


work

public abstract java.lang.Object work()
                               throws java.lang.Throwable
Compute the value to be returned by the get method.

Throws:
java.lang.Throwable

finished

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


interrupt

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


get

public java.lang.Object get()
Return the value created by the work method. Returns null if either the constructing thread or the current thread was interrupted before a value was produced.

Returns:
the value created by the work method

start

public void start()
Start the worker thread.


run

public java.lang.Object run()
                     throws java.lang.Throwable
Run the work in the calling thread, and then the notifier callback.

Throws:
java.lang.Throwable


Copyright © 2002 Romain Guy.