public class DeterminateProgressMonitor
extends java.lang.Object
A progress monitor implementation for determinate progress feedback.
This class is based on Swing's ProgressMonitor
, but the implementation conforms to user interface specifications and offers the following additional features:
By default, the progress monitor will not use a delay before making the dialog visible. Recommended settings for the popup decision and delay are 500 and 2000 milliseconds respectively. Thread advice - instances of this class should be configured and their methods invoked from a consumer worker thread and not the AWT event dispatcher thread, which must be left free to process events.
IndeterminateProgressMonitor
Constructor and Description |
---|
DeterminateProgressMonitor(java.awt.Component parent, java.lang.String title) |
DeterminateProgressMonitor(java.awt.Component parent, java.lang.String title, int min, int max) |
DeterminateProgressMonitor(java.awt.Component parent, java.lang.String title, java.lang.Object message, java.lang.String note) |
DeterminateProgressMonitor(java.awt.Component parent, java.lang.String title, java.lang.Object message, java.lang.String note, int min, int max) |
Modifier and Type | Method and Description |
---|---|
void |
addCancellationListener(javax.swing.event.ChangeListener l)
Adds a listener for progress dialog cancellation.
|
void |
close()
Indicates that the operation is complete.
|
protected void |
closeImpl() |
protected javax.swing.JProgressBar |
createProgressBar() |
void |
display()
Forces the progress dialog to be displayed, regardless of timing.
|
protected void |
displayImpl() |
void |
finish()
Finishes progress indication by setting the level to its maximum ahead of monitor closure.
|
protected void |
finishImpl(javax.swing.JProgressBar progressBar) |
boolean |
getCloseOnFinish()
Asks whether the monitor's dialog will close when responding to the
finish() method. |
java.awt.Component |
getComponent()
Gets the progress monitor dialog component, if created.
|
java.awt.Component |
getDetailContent()
Returns the content of the dialog to appear in a 'details' section.
|
int |
getMaximum()
Returns the maximum value -- the higher end of the progress value.
|
int |
getMillisToDecideToPopup()
Returns the amount of time this object waits before deciding whether or not to popup a progress monitor.
|
int |
getMillisToPopup()
Returns the amount of time it will take for the popup to appear.
|
int |
getMinimum()
Returns the minimum value -- the lower end of the progress value.
|
ProgressPanel |
getPanel()
Gets the panel component for this progress monitor.
|
int |
getProgress()
Get the current progress.
|
void |
incProgress()
Increment the current progress by one.
|
void |
incProgress(int increment)
Increment the current progress by the specified amount
|
boolean |
isBarVisible()
Returns the visibility of the dialog's progress bar before it is shown.
|
boolean |
isCanceled()
Returns true if the user hits the Cancel button in the progress dialog.
|
boolean |
isCancellable()
Returns whether the progress dialog can be cancelled.
|
boolean |
isCancelled()
Returns true if the user hits the Cancel button in the progress dialog.
|
boolean |
isDetailVisible()
Gets whether the dialog detail content is made visible by default.
|
boolean |
isModal() |
void |
removeCancellationListener(javax.swing.event.ChangeListener l)
Removes a listener for progress dialog cancellation.
|
void |
setBarVisible(boolean barVisible)
Specifies the visibility of the dialog's progress bar before it is shown.
|
void |
setCancellable(boolean cancellable)
Specifies whether the progress dialog can be cancelled.
|
void |
setCloseOnFinish(boolean closeOnFinish)
Sets whether the monitor's dialog should close when responding to the
finish() method. |
void |
setDetailContent(java.awt.Component detailContent)
Specifies the content of the dialog to appear in a 'details' section.
|
void |
setDetailVisible(boolean detailVisible)
Sets whether the dialog detail content is made visible by default.
|
void |
setMaximum(int m)
Specifies the maximum value.
|
void |
setMillisToDecideToPopup(int millisToDecideToPopup)
Specifies the amount of time to wait before deciding whether or not to popup a progress monitor.
|
void |
setMillisToPopup(int millisToPopup)
Specifies the amount of time it will take for the popup to appear.
|
void |
setMinimum(int m)
Specifies the minimum value.
|
void |
setModal(boolean isModal) |
void |
setProgress(int nv)
Indicates the progress of the operation being monitored.
|
void |
start()
Starts the monitor, ensuring the dialog will be displayed after the configured delay.
|
void |
startImpl()
Starts the monitor, ensuring the dialog will be displayed after the configured delay.
|
void |
uncancel()
Resets the cancelled state of the progress dialog.
|
public DeterminateProgressMonitor(java.awt.Component parent, java.lang.String title)
public DeterminateProgressMonitor(java.awt.Component parent, java.lang.String title, int min, int max)
public DeterminateProgressMonitor(java.awt.Component parent, java.lang.String title, java.lang.Object message, java.lang.String note)
public DeterminateProgressMonitor(java.awt.Component parent, java.lang.String title, java.lang.Object message, java.lang.String note, int min, int max)
public int getProgress()
public void incProgress()
public void incProgress(int increment)
increment
- amount to increase progress bypublic void startImpl()
public void setProgress(int nv)
nv
- an int specifying the current value, between the maximum and minimum specified for this componentsetMinimum(int)
, setMaximum(int)
, close()
public int getMinimum()
setMinimum(int)
public void setMinimum(int m)
m
- an int specifying the minimum valuegetMinimum()
public int getMaximum()
setMaximum(int)
public void setMaximum(int m)
m
- an int specifying the maximum valuegetMaximum()
public void setMillisToDecideToPopup(int millisToDecideToPopup)
millisToDecideToPopup
- an int specifying the time to wait, in millisecondsgetMillisToDecideToPopup()
public int getMillisToDecideToPopup()
setMillisToDecideToPopup(int)
protected javax.swing.JProgressBar createProgressBar()
protected void finishImpl(javax.swing.JProgressBar progressBar)
public void setCloseOnFinish(boolean closeOnFinish)
finish()
method. By default, this is true
.closeOnFinish
- a decision on dialog closure.public boolean getCloseOnFinish()
finish()
method.public void start()
public void finish()
public void close()
public boolean isCanceled()
public void addCancellationListener(javax.swing.event.ChangeListener l)
public void removeCancellationListener(javax.swing.event.ChangeListener l)
public void setMillisToPopup(int millisToPopup)
millisToPopup
- an int specifying the time in millisecondsgetMillisToPopup()
public int getMillisToPopup()
setMillisToPopup(int)
public void setDetailContent(java.awt.Component detailContent)
detailContent
- the detail content component.getDetailContent()
public java.awt.Component getDetailContent()
setDetailContent(java.awt.Component)
public void setDetailVisible(boolean detailVisible)
detailVisible
- true
if dialog detail will be made visible.public boolean isDetailVisible()
true
if dialog detail will be made visible.public void setBarVisible(boolean barVisible)
true
.barVisible
- the visibility value.isBarVisible()
public boolean isBarVisible()
setBarVisible(boolean)
public void setCancellable(boolean cancellable)
true
.cancellable
- the cancellable value.isCancellable()
public boolean isCancellable()
setCancellable(boolean)
public void display()
close()
public java.awt.Component getComponent()
public boolean isCancelled()
public void uncancel()
public ProgressPanel getPanel()
protected void displayImpl()
protected void closeImpl()
public final boolean isModal()
public final void setModal(boolean isModal)