File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Question of using the ProgressMonitor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Question of using the ProgressMonitor" Watch "Question of using the ProgressMonitor" New topic
Author

Question of using the ProgressMonitor

Stephen Lee
Ranch Hand

Joined: Dec 11, 2001
Posts: 74
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question of using the ProgressMonitor