Java Reference
In-Depth Information
The millisToDecideToPopup property represents the number of milliseconds that the
monitor waits before deciding if it needs to display the pop-up window. If the progress property
hasn't changed yet, the monitor waits for another increment of this time period before checking
again. When the ProgressMonitor checks and the progress property has changed, it estimates
whether the task will be completed in the number of milliseconds in the millisToPopup property.
If the ProgressMonitor thinks the monitored task will complete on time, the pop-up window is
never displayed. Otherwise, the pop-up will display after millisToPopup milliseconds have
passed from the time the task started.
Caution Although technically possible, it isn't a good practice to move the minimum and maximum properties
after the pop-up has appeared. This could result in the progress bar increasing and decreasing in an erratic
manner. The same behavior happens if you move the progress setting in a nonlinear fashion.
Customizing a ProgressMonitor Look and Feel
Changing the look and feel of ProgressMonitor requires changing the appearance of both the
JProgressBar and the JLabel , as well as the JOptionPane the ProgressMonitor uses.
The ProgressMonitor has one UIResource -related property:
ProgressMonitor.progressText of type String
ProgressMonitorInputStream Class
The ProgressMonitorInputStream class represents an input stream filter that uses a
ProgressMonitor to check the progress of the reading of an input stream. If the reading is
taking too long to complete, a ProgressMonitor appears, and the user can select the Cancel
button in the pop-up window, causing the reading to be interrupted and the input stream to
throw an InterruptedIOException .
Creating a ProgressMonitorInputStream
Like other filtering streams, the ProgressMonitorInputStream is created with a reference
to the stream it needs to filter. Besides a reference to this filter, the single constructor for
ProgressMonitorInputStream requires two arguments for its ProgressMonitor : a parent compo-
nent and a message. As seen here, the constructor takes the ProgressMonitor arguments first:
public ProgressMonitorInputStream(
Component parentComponent, Object message, InputStream inputStream)
As with the JOptionPane and ProgressMonitor , the message argument is an Object , not a
String , so you can display an array of components or strings on multiple lines. The following
code creates one ProgressMonitorInputStream .
 
Search WWH ::




Custom Search