Package org.jdesktop.application
Interface TaskListener<T,V>
-
- Type Parameters:
T
- the result type returned by thisSwingWorker's
doInBackground
andget
methodsV
- the type used for carrying out intermediate results by thisSwingWorker's
publish
andprocess
methods
- All Known Implementing Classes:
TaskListener.Adapter
public interface TaskListener<T,V>
Listener used for observingTask
execution. ATaskListener
is particularly useful for monitoring the the intermediate resultspublished
by a Task in situations where it's not practical to override the Task'sprocess
method. Note that if what you really want to do is monitor a Task's state and progress, a PropertyChangeListener is probably more appropriate.The Task class runs all TaskListener methods on the event dispatching thread and the source of all TaskEvents is the Task object.
- Author:
- Hans Muller (Hans.Muller@Sun.COM)
- See Also:
Task.addTaskListener(org.jdesktop.application.TaskListener<T, V>)
,Task.removeTaskListener(org.jdesktop.application.TaskListener<T, V>)
,SwingWorker.addPropertyChangeListener(java.beans.PropertyChangeListener)
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
TaskListener.Adapter<T,V>
Convenience class that stubs all of the TaskListener interface methods.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
cancelled(TaskEvent<java.lang.Void> event)
Called after the Task'scancelled
method is called.void
doInBackground(TaskEvent<java.lang.Void> event)
Called just before the Task'sdoInBackground
method is called, i.e.void
failed(TaskEvent<java.lang.Throwable> event)
Called after the Task'sfailed
completion method is called.void
finished(TaskEvent<java.lang.Void> event)
Called after the Task'sfinished
method is called.void
interrupted(TaskEvent<java.lang.InterruptedException> event)
Called after the Task'sinterrupted
method is called.void
process(TaskEvent<java.util.List<V>> event)
Called each time the Task'sprocess
method is called.void
succeeded(TaskEvent<T> event)
Called after the Task'ssucceeded
completion method is called.
-
-
-
Method Detail
-
doInBackground
void doInBackground(TaskEvent<java.lang.Void> event)
Called just before the Task'sdoInBackground
method is called, i.e. just before the task begins running. Theevent's
source is the Task and its value is null.- Parameters:
event
- a TaskEvent whose source is theTask
object, value is null- See Also:
SwingWorker.doInBackground()
,EventObject.getSource()
-
process
void process(TaskEvent<java.util.List<V>> event)
Called each time the Task'sprocess
method is called. The value of the event is the list of values passed to the process method.- Parameters:
event
- a TaskEvent whose source is theTask
object and whose value is a list of the values passed to theTask.process()
method- See Also:
SwingWorker.doInBackground()
,Task.process(java.util.List<V>)
,EventObject.getSource()
,TaskEvent.getValue()
-
succeeded
void succeeded(TaskEvent<T> event)
Called after the Task'ssucceeded
completion method is called. The event's value is the value returned by the Task'sget
method, i.e. the value that is computed bySwingWorker.doInBackground()
.- Parameters:
event
- a TaskEvent whose source is theTask
object, and whose value is the value returned byTask.get()
.- See Also:
Task.succeeded(T)
,EventObject.getSource()
,TaskEvent.getValue()
-
failed
void failed(TaskEvent<java.lang.Throwable> event)
Called after the Task'sfailed
completion method is called. The event's value is the Throwable passed toTask.failed()
.- Parameters:
event
- a TaskEvent whose source is theTask
object, and whose value is the Throwable passed toTask.failed()
.- See Also:
Task.failed(java.lang.Throwable)
,EventObject.getSource()
,TaskEvent.getValue()
-
cancelled
void cancelled(TaskEvent<java.lang.Void> event)
Called after the Task'scancelled
method is called. Theevent's
source is the Task and its value is null.- Parameters:
event
- a TaskEvent whose source is theTask
object, value is null- See Also:
Task.cancelled()
,SwingWorker.get()
,EventObject.getSource()
-
interrupted
void interrupted(TaskEvent<java.lang.InterruptedException> event)
Called after the Task'sinterrupted
method is called. Theevent's
source is the Task and its value is the InterruptedException passed toTask.interrupted()
.- Parameters:
event
- a TaskEvent whose source is theTask
object, and whose value is the InterruptedException passed toTask.interrupted()
.- See Also:
Task.interrupted(java.lang.InterruptedException)
,EventObject.getSource()
,TaskEvent.getValue()
-
finished
void finished(TaskEvent<java.lang.Void> event)
Called after the Task'sfinished
method is called. Theevent's
source is the Task and its value is null.- Parameters:
event
- a TaskEvent whose source is theTask
object, value is null.- See Also:
Task.interrupted(java.lang.InterruptedException)
,EventObject.getSource()
-
-