This week's book giveaway is in the Spring forum.
We're giving away four copies of Spring in Action (5th edition) and have Craig Walls on-line!
See this thread for details.
Win a copy of Spring in Action (5th edition) this week in the Spring forum!
  • 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:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

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!