• Post Reply Bookmark Topic Watch Topic
  • New Topic

progress monitor not showing  RSS feed

 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i thought that simply constructing a progressmonitor would show the dialog, and wrote the following code.

but apparently i was wrong and all i get is an empty JFrame and no Dialog.
I even added my own subclass of SwingWorker in case a SwingWorker had to be created in order for a progress monitor to exist.
how can I make it show?
 
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See this: http://docs.oracle.com/javase/tutorial/uiswing/components/progress.html#monitors

The ProgressMonitor itself is not a visible component, it just tracks progress and if it figures the progress will take long enough it will pop up a dialog. The dialog only appears if the the monitor determines if the process will take longer than 2 seconds, and it doesn't make that decision until about a half second into the operation. It makes the decision based on how far the progress has gone in the time allotted. (both the 2 second task time and the 500ms determination time are configurable). In your example, you immediately set the progress to 30 percent done, so it looks like the operation could finish quickly and the dialog won't show. What you should do instead of setting the progress to 30 in the constructor is use your SwingWorker to sleep for a little bit then update the monitor so there is enough time for the monitor to realize: (1) the task is progressing, and (2) it will take long enough to need a progress bar.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!