public class ProgressBar
extends java.lang.Object
implements java.awt.event.ActionListener, java.lang.Runnable
ProgressBar
provides the user with feedback while a
long-running process is in progress. The dialog consists of a label
known as the progressText, a progress indicator, and another label known
as the stepText.The progress indicator displayed is the javax.swing.JProgressBar
Client code must implement the Runnable interface in order to use the
ProgressBar
. The ProgressBar will create a new thread and
invoke the run() method in the Runnable passed in via the constructor.
This is done so the UI can be repainted while the long-running process is
executing.
Extension developers should not rely on the fact that this class
implements ActionListener and Runnable. These are implementation details
of this class, and should not have been exposed. Extension developers should
also assume that this class is final.
Modifier and Type | Field and Description |
---|---|
protected javax.swing.JLabel |
_progressLabel
The label that displays the top line of progress text
|
protected DetailDialog |
_statusDialog
The dialog which displays the current font calculations status.
|
Constructor and Description |
---|
ProgressBar(java.awt.Component parent,
java.lang.String dialogTitle,
java.lang.Runnable runnable,
boolean useBusyBar)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent event)
Deprecated.
since 11.1.1 this method should not have been exposed as a
public API.
|
int |
getCompletionStatus()
Gets the amount of progress that has been reported so far.
|
java.lang.String |
getProgressText()
Get the progress text
|
java.lang.String |
getStepText()
Get the step text.
|
boolean |
hasUserCancelled()
The client code's run() method that implements the long-running
process should call this method to determine if the user
has pressed the Cancel button on the ProgressBar's dialog to
terminate the long-running process.
|
boolean |
hasUserPressedCustomButton()
The client code's run() method that implements the long-running
process should call this method to determine if the user
has pressed the custom button on the ProgressBar's dialog to terminate
or simply dismiss the dialog, depending on the purpose of the custom
button.
|
boolean |
hasUserPressedOkButton()
This method returns true if the user pressed the OK button in order to
dismiss the dialog.
|
boolean |
isCancelable() |
void |
run()
Deprecated.
since 11.1.1 this method should not have been exposed as
a public API.
|
protected void |
runPostCompletionTasks()
Executes tasks after the long-running process is complete, but only if the
progress dialog is to remain visible post-completion.
|
void |
setCancelable(boolean canCancel) |
void |
setCustomButton(javax.swing.JButton customButton)
Adds a custom button to the dialog, to be displayed alongside the OK and Cancel buttons.
|
void |
setCustomButtonEnabled(boolean enabled)
Sets the enablement status of the custom button, if any.
|
void |
setCustomDialogButtonMask(int mask) |
void |
setDetailsButtonEnabled(boolean enabled) |
void |
setDialogName(java.lang.String dialogName)
Explicitly sets the name of the dialog used by the progress bar to
facilitate automated testing.
|
void |
setDialogResizable(boolean resizable) |
void |
setDoneStatus()
The client code should call this when the long-running process is
complete.
|
void |
setHideDetailsText(java.lang.String hideDetailsText)
Set the label of the Details button when the details are shown.
|
void |
setOKButtonText(java.lang.String okButtonText)
Attempts to immediately update the text of the dialog's OK button.
|
void |
setProgressDetailContent(java.awt.Component customContent,
java.lang.String okButtonText,
boolean initialButtonState) |
void |
setRunnable(java.lang.Runnable runnable) |
void |
setShowDetailsText(java.lang.String showDetailsText)
Set the label of the Details button when the details are hidden.
|
void |
sleepForUIToRepaint()
The client code should call this in it's run() method that implements
the long-running process.
|
void |
start(java.lang.String initialText,
java.lang.String stepText)
Starts the ProgressBar with a default range (0-100).
|
void |
start(java.lang.String initialText,
java.lang.String stepText,
int delay)
Starts the ProgressBar with a default range (0-100) after a delay.
|
void |
start(java.lang.String initialText,
java.lang.String stepText,
int min,
int max)
Starts the ProgressBar with a specified range.
|
void |
start(java.lang.String initialText,
java.lang.String stepText,
int min,
int max,
int delay)
Starts the ProgressBar with a specified range after a delay.
|
void |
start(java.lang.String initialText,
java.lang.String stepText,
int min,
int max,
int wcDelay,
int delay)
Starts the ProgressBar with a specified range after a delay.
|
void |
updateProgress(int completionStatus,
java.lang.String progressText,
java.lang.String stepText)
The client code's run() method that implements the long-running
process should use this method to update the ProgressBar to indicate
the progress made in the long-running process.
|
void |
updateProgress(java.lang.String progressText,
java.lang.String stepText)
The client code's run() method that implements the long-running
process should use this method to update the ProgressBar to
indicate the progress made in the long-running process.
|
void |
waitUntilDone()
The client code should call this to wait until the long-running
process is complete.
|
protected final javax.swing.JLabel _progressLabel
protected DetailDialog _statusDialog
public ProgressBar(java.awt.Component parent, java.lang.String dialogTitle, java.lang.Runnable runnable, boolean useBusyBar)
parent
- The UI object to use as the ProgressBar dialog's parentdialogTitle
- The title to use for the ProgressBar dialogrunnable
- The Runnable object whose run() method implements the
long-running processuseBusyBar
- Set to true when the task is indeterminate;
false when the the task is determinatepublic void setRunnable(java.lang.Runnable runnable)
public void setDialogName(java.lang.String dialogName)
dialogName
- The name for the progress bar dialogpublic void setDialogResizable(boolean resizable)
public void setProgressDetailContent(java.awt.Component customContent, java.lang.String okButtonText, boolean initialButtonState)
public void setShowDetailsText(java.lang.String showDetailsText)
public void setOKButtonText(java.lang.String okButtonText)
public void setHideDetailsText(java.lang.String hideDetailsText)
public void setCustomButton(javax.swing.JButton customButton)
customButton
- The button to set.public void setCustomButtonEnabled(boolean enabled)
public void setDetailsButtonEnabled(boolean enabled)
enabled
- Whether or not the dialog's details button (if any) should be enabled.public void setCustomDialogButtonMask(int mask)
mask
- The mask that determines which buttons the dialog will contain.public void setCancelable(boolean canCancel)
public boolean isCancelable()
public void start(java.lang.String initialText, java.lang.String stepText)
initialText
- The text to display just above the progress
indicator. An example might be "Downloading components."stepText
- The text to display just below the progress
indicator. An example might be "Retrieving file abc.jar."public void start(java.lang.String initialText, java.lang.String stepText, int delay)
initialText
- The text to display just above the progress
indicator. An example might be "Downloading components."stepText
- The text to display just below the progress
indicator. An example might be "Retrieving file abc.jar."delay
- The number of milliseconds to wait before showing the
progress dialogpublic void start(java.lang.String initialText, java.lang.String stepText, int min, int max)
initialText
- The text to display just above the progress
indicator. An example might be "Downloading components."stepText
- The text to display just below the progress
indicator. An example might be "Retrieving file abc.jar."min
- the minimum progress to report (typically this will be 0)max
- the maximum progress to be reportedpublic void start(java.lang.String initialText, java.lang.String stepText, int min, int max, int delay)
initialText
- The text to display just above the progress
indicator. An example might be "Downloading components."stepText
- The text to display just below the progress
indicator. An example might be "Retrieving file abc.jar."min
- the minimum progress to report (typically this will be 0)max
- the maximum progress to be reporteddelay
- The number of milliseconds to wait before showing the
progress dialogpublic void start(java.lang.String initialText, java.lang.String stepText, int min, int max, int wcDelay, int delay)
initialText
- The text to display just above the progress
indicator. An example might be "Downloading components."stepText
- The text to display just below the progress
indicator. An example might be "Retrieving file abc.jar."min
- the minimum progress to report (typically this will be 0)max
- the maximum progress to be reportedwcDelay
- The number of milliseconds to wait before showing the
wait cursor. If less than 0, the wait cursor will not be showndelay
- The number of milliseconds to wait before showing the
progress dialogpublic void updateProgress(int completionStatus, java.lang.String progressText, java.lang.String stepText)
completionStatus
- The amount of progress that has been made.progressText
- The text to display just above the progress
indicator. If a null string or zero-length string is passed
in the text will not be updated.stepText
- The text to display just below the progress indicator.
If a null string or zero-length string is passed
in the text will not be updated.public int getCompletionStatus()
public java.lang.String getStepText()
public java.lang.String getProgressText()
public void updateProgress(java.lang.String progressText, java.lang.String stepText)
progressText
- The text to display just above the progress
indicator. If a null string or zero-length string is passed
in the text will not be updated.stepText
- The text to display just below the progress indicator.
If a null string or zero-length string is passed
in the text will not be updated.public boolean hasUserCancelled()
public boolean hasUserPressedCustomButton()
public boolean hasUserPressedOkButton()
public void sleepForUIToRepaint()
public void waitUntilDone()
public void setDoneStatus()
@Deprecated public void actionPerformed(java.awt.event.ActionEvent event)
actionPerformed
in interface java.awt.event.ActionListener
event
- the action eventprotected void runPostCompletionTasks()
@Deprecated public void run()
run
in interface java.lang.Runnable