Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Question of using the ProgressMonitor  RSS feed

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!