FileDocCategorySizeDatePackage
LongTask.javaAPI DocExample2092Tue Dec 12 18:59:20 GMT 2000None

LongTask

public class LongTask extends Object
Uses a SwingWorker to perform a time-consuming (and utterly fake) task.

Fields Summary
private int
lengthOfTask
private int
current
private String
statMessage
Constructors Summary
LongTask()


     
        //Compute length of task...
        //In a real program, this would figure out
        //the number of bytes to read or whatever.
        lengthOfTask = 1000;
    
Methods Summary
booleandone()
Called from ProgressBarDemo to find out if the task has completed.

        if (current >= lengthOfTask)
            return true;
        else
            return false;
    
intgetCurrent()
Called from ProgressBarDemo to find out how much has been done.

        return current;
    
intgetLengthOfTask()
Called from ProgressBarDemo to find out how much work needs to be done.

        return lengthOfTask;
    
java.lang.StringgetMessage()

        return statMessage;
    
voidgo()
Called from ProgressBarDemo to start the task.

        current = 0;
        final SwingWorker worker = new SwingWorker() {
            public Object construct() {
                return new ActualTask();
            }
        };
        worker.start();
    
voidstop()

        current = lengthOfTask;