Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
javax.swing.ProgressMonitor
public class ProgressMonitor
extends Object
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
.
Field Summary | |
protected AccessibleContext |
|
Constructor Summary | |
|
Method Summary | |
void |
|
AccessibleContext |
|
int |
|
int |
|
int |
|
int |
|
String |
|
boolean |
|
void |
|
void |
|
void |
|
void |
|
void | |
void |
|
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
protected AccessibleContext accessibleContext
The accessible content for this component
public ProgressMonitor(Component component, Object message, String note, int minimum, int maximum)
Creates a newProgressMonitor
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 ornull
.message
- A constant message object which works in the way it does inJOptionPane
.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).
public void close()
Hides the dialog and stops any measurements.Has no effect when
setProgress
is not at least called once.
public AccessibleContext getAccessibleContext()
Gets the accessible context.
- Returns:
- the accessible context.
public int getMaximum()
Return the maximum or end value of your operation.
- Returns:
- Maximum or end value.
public int getMillisToDecideToPopup()
Returns the amount of milliseconds to wait until the ProgressMonitor should decide whether a progress dialog is to be shown or not.
- Returns:
- The duration in milliseconds.
public int getMillisToPopup()
Returns the number of milliseconds to wait before displaying the progress dialog. The default value is 2000.
- Returns:
- The number of milliseconds.
- See Also:
setMillisToPopup(int)
public int getMinimum()
Returns the minimum or start value of the operation.
- Returns:
- Minimum or start value of the operation.
public String getNote()
Returns a message which is shown in the progress dialog.
- Returns:
- The changeable message visible in the progress dialog.
public boolean isCanceled()
Returns whether the user canceled the operation.
- Returns:
- Whether the operation was canceled.
public void setMaximum(int maximum)
Sets the maximum or end value of the operation to the given integer.
- Parameters:
maximum
-
public 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.This method has no effect when the progress dialog is already visible.
- Parameters:
time
- The duration in milliseconds.
public void setMillisToPopup(int time)
Sets the number of milliseconds to wait before displaying the progress dialog.
- Parameters:
time
- the number of milliseconds.
- See Also:
getMillisToPopup()
public 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.
- Parameters:
minimum
- The new minimum value.
public void setNote(String note)
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.
public void setProgress(int progress)
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.