javax.swing
public class ProgressMonitor extends Object
Using this class you can easily monitor tasks where you cannot estimate the duration exactly.
A ProgressMonitor instance waits until the first time setProgress
is called. When millisToDecideToPopup
time elapsed the
instance estimates the duration until the whole operation is completed.
If this duration exceeds millisToPopup
a non-modal dialog
with a message and a progress bar is shown.
The value of millisToDecideToPopup
defaults to
500
and millisToPopup
to
2000
.
Since: 1.2
UNKNOWN: updated to 1.2
Field Summary | |
---|---|
protected AccessibleContext | accessibleContext
The accessible content for this component |
Constructor Summary | |
---|---|
ProgressMonitor(Component component, Object message, String note, int minimum, int maximum)
Creates a new ProgressMonitor instance. |
Method Summary | |
---|---|
void | close() Hides the dialog and stops any measurements. Has no effect when |
AccessibleContext | getAccessibleContext()
Gets the accessible context.
|
int | getMaximum()
Return the maximum or end value of your operation.
|
int | getMillisToDecideToPopup()
Returns the amount of milliseconds to wait
until the ProgressMonitor should decide whether
a progress dialog is to be shown or not.
|
int | getMillisToPopup()
Returns the number of milliseconds to wait before displaying the progress
dialog. |
int | getMinimum()
Returns the minimum or start value of the operation.
|
String | getNote()
Returns a message which is shown in the progress dialog.
|
boolean | isCanceled()
Returns whether the user canceled the operation.
|
void | setMaximum(int maximum) Sets the maximum or end value of the operation to the given integer. |
void | setMillisToDecideToPopup(int time)
Sets the amount of milliseconds to wait until the
ProgressMonitor should decide whether a progress dialog
is to be shown or not.
|
void | setMillisToPopup(int time)
Sets the number of milliseconds to wait before displaying the progress
dialog.
|
void | setMinimum(int minimum) Use this method to set the minimum or start value of your operation. For typical application like copy operation this will be zero. Keep in mind that changing this value after the progress dialog is made visible has no effect upon the progress bar. |
void | setNote(String note) Set the message shown in the progess dialog. Changing the note while the progress dialog is visible is possible. |
void | setProgress(int progress) Updates the progress value. When called for the first time this initializes a timer
which decides after If the progress value equals or exceeds the maximum value the progress dialog is closed automatically. |
ProgressMonitor
instance. This is used to
monitor a task and pops up a dialog if the task is taking a long time to
run.
Parameters: component The parent component of the progress dialog or
null
. message A constant message object which works in the way it does
in {@link JOptionPane}. note A string message which can be changed while the operation goes
on. minimum The minimum value for the operation (start value). maximum The maximum value for the operation (end value).
Hides the dialog and stops any measurements.
Has no effect when setProgress
is not at least
called once.
Returns: the accessible context.
Returns: Maximum or end value.
Returns: The duration in milliseconds.
Returns: The number of milliseconds.
See Also: ProgressMonitor
Returns: Minimum or start value of the operation.
Returns: The changeable message visible in the progress dialog.
Returns: Whether the operation was canceled.
Sets the maximum or end value of the operation to the given integer.
Parameters: maximum
This method has no effect when the progress dialog is already visible.
Parameters: time The duration in milliseconds.
Parameters: time the number of milliseconds.
See Also: getMillisToPopup
Use this method to set the minimum or start value of your operation.
For typical application like copy operation this will be zero.
Keep in mind that changing this value after the progress dialog is made visible has no effect upon the progress bar.
Parameters: minimum The new minimum value.
Set the message shown in the progess dialog.
Changing the note while the progress dialog is visible is possible.
Parameters: note A message shown in the progress dialog.
Updates the progress value.
When called for the first time this initializes a timer
which decides after millisToDecideToPopup
time
whether to show a progress dialog or not.
If the progress value equals or exceeds the maximum value the progress dialog is closed automatically.
Parameters: progress New progress value.