java.lang.Object
org.monte.media.swing.BackgroundTask
- All Implemented Interfaces:
Runnable
This is an abstract class that you can subclass to
perform GUI-related work in a dedicated event dispatcher.
This class is similar to SwingWorker but less complex.
- Author:
- Werner Randelshofer
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidCompute the value to be returned by thegetmethod.protected voiddone()Called on the event dispatching thread (not on the worker thread) after theconstructmethod has returned without throwing an error.protected voidCalled on the event dispatching thread (not on the worker thread) after theconstructmethod has thrown an error.protected voidfinished()Called on the event dispatching thread (not on the worker thread) after theconstructmethod has finished and after done() or failed() has been invoked.protected ThrowablegetError()Get the error produced by the worker thread, or null if it hasn't thrown one.final voidrun()Calls #construct on the current thread and invokes #done on the AWT event dispatcher thread.voidstart()Starts the Worker on an internal worker thread.
-
Constructor Details
-
BackgroundTask
public BackgroundTask()
-
-
Method Details
-
run
public final void run()Calls #construct on the current thread and invokes #done on the AWT event dispatcher thread. -
construct
Compute the value to be returned by thegetmethod.- Throws:
Exception
-
done
protected void done()Called on the event dispatching thread (not on the worker thread) after theconstructmethod has returned without throwing an error.The default implementation does nothing. Subclasses may override this method to perform done actions on the Event Dispatch Thread.
-
failed
Called on the event dispatching thread (not on the worker thread) after theconstructmethod has thrown an error.The default implementation prints a stack trace. Subclasses may override this method to perform failure actions on the Event Dispatch Thread.
- Parameters:
error- The error thrown by construct.
-
finished
protected void finished()Called on the event dispatching thread (not on the worker thread) after theconstructmethod has finished and after done() or failed() has been invoked.The default implementation does nothing. Subclasses may override this method to perform completion actions on the Event Dispatch Thread.
-
getError
Get the error produced by the worker thread, or null if it hasn't thrown one. -
start
public void start()Starts the Worker on an internal worker thread.
-