public abstract class Task extends Object
Title: 常用代码打包
Description: This is the parent class of what performs a time consuming task. It can also interract with ProgressDialog to monitor the process of the task.
Copyright: Copyright (c) 2006
Company: www.justdos.net
| 构造器和说明 |
|---|
Task() |
| 限定符和类型 | 方法和说明 |
|---|---|
abstract void |
cancel()
Invoked by ProgressDialog when the task is canceled or an error occured.
|
abstract void |
complete()
Invoked by ProgressDialog when the task is completed.
|
boolean |
done()
ProgressDialog use this method to adjust whether the task has done.
|
int |
getCurrent()
Gets the current attribute of the Task object
|
boolean |
getHasError()
ProgressDialog will timely check the return value of this method to adjust
whether an error accured.
|
int |
getLengthOfTask()
Gets the lengthOfTask attribute of the Task object
|
String |
getMessage()
Gets the message attribute of the Task object
|
abstract void |
go()
Sample:
public void go() { |
void |
setCurrent(int current)
Sets the current attribute of the Task object
|
void |
setHasError(boolean hasError)
If you catch an Exception or have other reason to stop the task and not
regard it as completed, pass true to this method.
|
void |
setLengthOfTask(int lengthOfTask)
Sets the lengthOfTask attribute of the Task object
|
void |
setMessage(String statMessage)
Sets the message attribute of the Task object
|
void |
stop()
Stop this task.
|
public abstract void go()
public void go() {
final SwingWorker worker = new SwingWorker() {
public Object construct() {
// time consuming task here...
// return a Object class that SwingWorker needed
return new Object();
}}}
public abstract void cancel()
public abstract void complete()
public void stop()
public void setHasError(boolean hasError)
hasError - The new hasError valuepublic boolean getHasError()
public boolean done()
public int getLengthOfTask()
public void setLengthOfTask(int lengthOfTask)
lengthOfTask - The new lengthOfTask valuepublic int getCurrent()
public void setCurrent(int current)
current - The new current valuepublic String getMessage()
public void setMessage(String statMessage)
statMessage - The new message valueCopyright © 2023 onecode. All rights reserved.