public class LoadImageTask extends Task<java.awt.image.BufferedImage,java.lang.Void>
progress
property
and messages are generated when the Task begins and when it
finishes. If errors occur then warnings are logged and the
Task's value is null.
Applications would typically use LoadImageTask by creating
a private subclass that overrode the done
method.
See SingleFrameExample5.java for an example.
Resources for this class are in the
resources/LoadImageTask.properties
ResourceBundle.
Task.BlockingScope, Task.InputBlocker
Constructor and Description |
---|
LoadImageTask(Application app,
java.net.URL url) |
Modifier and Type | Method and Description |
---|---|
protected void |
cancelled()
Called when this Task has been cancelled by
SwingWorker.cancel(boolean) . |
protected java.awt.image.BufferedImage |
doInBackground() |
protected void |
failed(java.lang.Throwable e)
Called when an execution of this Task fails and an
ExecutionExecption is thrown by get . |
protected void |
finished()
Called unconditionally (in a
finally clause) after one
of the completion methods, succeeded , failed ,
cancelled , or interrupted , runs. |
protected java.net.URL |
getImageURL() |
protected void |
interrupted(java.lang.InterruptedException e)
Called if the Task's Thread is interrupted but not
explicitly cancelled.
|
protected void |
succeeded(java.awt.image.BufferedImage image)
Called when this Task has successfully completed, i.e.
|
addTaskListener, done, getApplication, getContext, getDescription, getExecutionDuration, getInputBlocker, getMessage, getMessageDuration, getResourceMap, getTaskListeners, getTaskService, getTitle, getUserCanCancel, isPending, isProgressPropertyValid, isStarted, message, process, removeTaskListener, resourceName, setDescription, setInputBlocker, setMessage, setProgress, setProgress, setProgress, setTitle, setUserCanCancel
public LoadImageTask(Application app, java.net.URL url)
protected final java.net.URL getImageURL()
protected java.awt.image.BufferedImage doInBackground()
doInBackground
in class org.jdesktop.swingworker.SwingWorker<java.awt.image.BufferedImage,java.lang.Void>
protected void cancelled()
Task
SwingWorker.cancel(boolean)
.
This method runs on the EDT. It does nothing by default.
cancelled
in class Task<java.awt.image.BufferedImage,java.lang.Void>
Task.done()
protected void interrupted(java.lang.InterruptedException e)
Task
This method runs on the EDT. It does nothing by default.
interrupted
in class Task<java.awt.image.BufferedImage,java.lang.Void>
e
- the InterruptedException
thrown by get
SwingWorker.cancel(boolean)
,
Task.done()
,
SwingWorker.get()
protected void succeeded(java.awt.image.BufferedImage image)
Task
get
method returns a value. Tasks that compute
a value should override this method.
This method runs on the EDT. It does nothing by default.
succeeded
in class Task<java.awt.image.BufferedImage,java.lang.Void>
image
- the value returned by the get
methodTask.done()
,
SwingWorker.get()
,
Task.failed(java.lang.Throwable)
protected void failed(java.lang.Throwable e)
Task
ExecutionExecption
is thrown by get
.
This method runs on the EDT. It Logs an error message by default.
failed
in class Task<java.awt.image.BufferedImage,java.lang.Void>
e
- the cause
of the ExecutionException
Task.done()
,
SwingWorker.get()
,
Task.failed(java.lang.Throwable)
protected void finished()
Task
finally
clause) after one
of the completion methods, succeeded
, failed
,
cancelled
, or interrupted
, runs. Subclasses
can override this method to cleanup before the done
method returns.
This method runs on the EDT. It does nothing by default.
finished
in class Task<java.awt.image.BufferedImage,java.lang.Void>
Task.done()
,
SwingWorker.get()
,
Task.failed(java.lang.Throwable)