public abstract class CommonsSwingWorker
extends java.lang.Object
Constructor and Description |
---|
CommonsSwingWorker()
Start a thread that will call the
construct method
and then exit. |
CommonsSwingWorker(int priority)
Start a thread that will call the
construct method
and then exit. |
Modifier and Type | Method and Description |
---|---|
abstract java.lang.Object |
construct()
Compute the value to be returned by the
get() method. |
static CommonsSwingWorker |
createWorker(int priority,
java.lang.Runnable preupdater,
int pretimeout,
java.lang.Runnable task,
java.lang.Runnable postupdater)
Creates a new worker instance with a task (separate thread) and GUI update code blocks (EDT).
|
void |
finished()
Called on the event dispatching thread (not on the worker thread)
after the
construct method has returned. |
java.lang.Object |
get()
Return the value created by the
construct method. |
protected 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.
|
void |
join()
Waits until the worker has been finished.
|
void |
start()
Start the worker thread.
|
public CommonsSwingWorker()
construct
method
and then exit.
public CommonsSwingWorker(int priority)
construct
method
and then exit.
The second constructor method receives the desired priority
of the Swing Worker thread. You may use values between
Thread.MIN_PRIORITY and Thread.MAX_PRIORITY here. For example
use this functionality if you encounter problems with GUI
updates while SwingWorker threads are running. You may then
decrease the priority of these threads to giv e the GUI more
chances to refresh.
priority
- Value between Thread.MIN_PRIORITY and Thread.MAX_PRIORITYprotected java.lang.Object getValue()
null
if it hasn't been constructed yet.
public abstract java.lang.Object construct()
get()
method.
get()
methodpublic void finished()
construct
method has returned.
public void interrupt()
public java.lang.Object get()
construct
method.
Returns null if either the constructing thread or the current
thread was interrupted before a value was produced.
construct
methodpublic void start()
public void join()
java.lang.IllegalStateException
- If called from EDTpublic static CommonsSwingWorker createWorker(int priority, java.lang.Runnable preupdater, int pretimeout, java.lang.Runnable task, java.lang.Runnable postupdater)
priority
- Value between Thread.MIN_PRIORITY and Thread.MAX_PRIORITYpreupdater
- Code to disable the GUI executed by EDT (optional)pretimeout
- Milliseconds to wait before the pre-update code is executed, 0=immediatelytask
- Code to be executed by a separate thread (required)postupdater
- Code to be executed by EDT finally (optional)Copyright © 2005-2013 Leisenfels UG (haftungsbeschränkt). All rights reserved.