By themselves, progress bars are pretty boring. Swing, however,
combines progress bars with the dialog capabilities of
JOptionPane to create the
ProgressMonitorInputStream classes. You can use
the first of these to report on the current progress of a potentially
long task. You can use
to automatically monitor the amount of data that has been read in
InputStream. With both, you can define
various strings to be posted in the progress monitor dialogs to offer
a better explanation of the task at hand.
class is a generic progress dialog box
that can be used for practically anything. There are two string
descriptions that can be set on a
dialog box. The first is a static component that can never change; it
appears on the top of the dialog and is set in the constructor. The
second is a variable string-based property that can be reset at any
time. It appears below the static string, slightly above the progress
bar. Figure 6.15 shows the structure for this class.
Figure 6-15. ProgressMonitor class diagram
Once instantiated, the
(shown in Figure 6.16) does not pop up immediately. The dialog waits a configurable amount of time before deciding whether the task at hand is long enough to warrant the dialog. If it is, the dialog is displayed. ...