[Logo]
Forums Register Login
Question of using the ProgressMonitor
I am making a swing product which use the JInternalFrame.
After the user open a file through the FileChooser, an JInternalFrame is opened. The process of opening the JInternalFrame needs more than 30 seconds, so I use the ProgressMonitor to represent the progress. So I make use of the files of ProgressMonitor, SwingWorker, and LongTask
from the java.sun.com.
However, I have some questions about the use of these files:
1) I don't know where I should put the code of the time-consuming task (opening of the file) to those class I got.
I now put it in the class ActualTask in the LongTask file -
class ActualTask {
ActualTask () {
myFrame.openFile(); // the method of the file opening
while (current < lengthOfTask) {<br /> try {<br /> Thread.sleep(1000); <br /> current += Math.random() * 100; <br /> if (current > lengthOfTask) {
current = lengthOfTask;
}
statMessage = "Completed " + current + " out of " + lengthOfTask +
".";
} catch (InterruptedException e) {}
}
}
}
actually, I found that it works, however, the progress dialog box does not appear until the JInternalFrame appears. That means the box
appears after the method.
Then where I should put the method of openFile() to.
[PS: the method openFile() does many things beside opening the file]
2) How can I determine the duration of the method? Should I estimate it?
Many Thanks!
Stephen

This thread has been viewed 738 times.

All times above are in ranch (not your local) time.
The current ranch time is
Dec 15, 2018 11:17:23.