|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container java.awt.Window java.awt.Dialog javax.swing.JDialog edu.northwestern.at.utils.swing.ModalDialog edu.northwestern.at.utils.swing.ProgressDialog
public class ProgressDialog
Displays a progress dialog.
The progress dialog has a title, an updateable label field for explaining the current progress of the task, a progress bar for visually displaying the current progress of the task, and an optional cancel button for cancelling the task.
By default the cancel button does nothing except to close the status dialog. Override the "doCancel" method to add any processing you need for a cancel action.
The progress dialog should always be attached to a process running in a separate thread. The progress dialog will not be updated correctly by Swing unless it is executing in a separate thread.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JDialog |
---|
javax.swing.JDialog.AccessibleJDialog |
Nested classes/interfaces inherited from class java.awt.Dialog |
---|
java.awt.Dialog.AccessibleAWTDialog, java.awt.Dialog.ModalExclusionType, java.awt.Dialog.ModalityType |
Nested classes/interfaces inherited from class java.awt.Window |
---|
java.awt.Window.AccessibleAWTWindow |
Nested classes/interfaces inherited from class java.awt.Container |
---|
java.awt.Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary | |
---|---|
protected boolean |
cancelled
True if progress dialog cancelled. |
protected java.awt.event.ActionListener |
cancelPressed
Handle Cancel button pressed. |
protected int |
currentBarValue
Current progress bar value. |
protected static long |
defaultStartupDelay
Default startup delay = 1.5 seconds. |
protected java.lang.String |
initLabel
The initial value of the explanatory message. |
protected javax.swing.JLabel |
label
Label for explanatory message. |
protected int |
labelWidth
Nice wide label size. |
protected int |
maxBar
Maximum value for progress bar. |
protected int |
minBar
Minimum value for progress bar. |
protected java.awt.Window |
parentWindow
Parent window for progress dialog. |
protected javax.swing.JProgressBar |
progressBar
Progress bar indicating how far work has progressed. |
protected long |
startupDelay
How many milliseconds to wait before displaying dialog. |
protected long |
startupTime
Startup time for dialog. |
Fields inherited from class edu.northwestern.at.utils.swing.ModalDialog |
---|
usePlatformPositionForDefaultButton |
Fields inherited from class javax.swing.JDialog |
---|
accessibleContext, rootPane, rootPaneCheckingEnabled |
Fields inherited from class java.awt.Dialog |
---|
DEFAULT_MODALITY_TYPE |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface javax.swing.WindowConstants |
---|
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
ProgressDialog(java.lang.String title,
java.lang.String initLabel,
int minBar,
int maxBar,
boolean allowCancel)
Create progress dialog. |
|
ProgressDialog(java.lang.String title,
java.lang.String initLabel,
int minBar,
int maxBar,
boolean allowCancel,
long startupDelay)
Create progress dialog. |
|
ProgressDialog(java.awt.Window parentWindow,
java.lang.String title,
java.lang.String initLabel,
int minBar,
int maxBar,
boolean allowCancel)
Create progress dialog. |
|
ProgressDialog(java.awt.Window parentWindow,
java.lang.String title,
java.lang.String initLabel,
int minBar,
int maxBar,
boolean allowCancel,
long startupDelay)
Create progress dialog. |
Method Summary | |
---|---|
void |
close()
Close the progress dialog. |
protected void |
doCancel()
Action to take when cancel button pressed. |
int |
getCurrentBarValue()
Get the current bar value. |
int |
getMaximumBarValue()
Get the maximum bar value. |
boolean |
isCancelled()
See if progress dialog cancelled. |
void |
makeVisible(boolean visible)
Make the dialog visible or invisble. |
void |
setIndeterminate(boolean isIndeterminate)
Set tbe progress bar determinate/indeterminate state. |
void |
setLabelColor(java.awt.Color color)
Set the progress label text color. |
void |
setMaximumBarValue(int maxBar)
Set maximum bar value. |
void |
setStartupTime(long startupTime)
Set the startup time. |
void |
setTitle(java.lang.String title)
Set the title. |
void |
updateProgress(int barValue)
Update progress display. |
void |
updateProgress(int barValue,
java.lang.String newLabel)
Update progress display. |
void |
updateProgress(java.lang.String newLabel)
Update progress display. |
Methods inherited from class edu.northwestern.at.utils.swing.ModalDialog |
---|
add, add, add, add, add, addButton, addDefaultButton, fixDefaultButtonPosition, getUsePlatformPositionForDefaultButton, paintImmediately, setInitialFocus, setUsePlatformPositionForDefaultButton, setVisible, show, showUnpacked, showUnpacked |
Methods inherited from class javax.swing.JDialog |
---|
addImpl, createRootPane, dialogInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update |
Methods inherited from class java.awt.Dialog |
---|
addNotify, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, setModal, setModalityType, setResizable, setUndecorated, show, toBack |
Methods inherited from class java.awt.Window |
---|
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeNotify, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImage, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, toFront |
Methods inherited from class java.awt.Container |
---|
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree |
Methods inherited from class java.awt.Component |
---|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected int minBar
protected int maxBar
protected javax.swing.JLabel label
protected java.lang.String initLabel
protected javax.swing.JProgressBar progressBar
protected int currentBarValue
protected boolean cancelled
protected static long defaultStartupDelay
protected long startupDelay
protected long startupTime
protected java.awt.Window parentWindow
protected int labelWidth
protected java.awt.event.ActionListener cancelPressed
Constructor Detail |
---|
public ProgressDialog(java.awt.Window parentWindow, java.lang.String title, java.lang.String initLabel, int minBar, int maxBar, boolean allowCancel, long startupDelay)
parentWindow
- The parent window.title
- Title for progress dialog.initLabel
- Initial text of label.minBar
- Minimum value for progress bar.maxBar
- Maximum value for progress bar.allowCancel
- Display a cancel button.startupDelay
- Startup delay. Dialog will not appear
until this many milliseconds have passed
since creation of dialog. public ProgressDialog(java.lang.String title, java.lang.String initLabel, int minBar, int maxBar, boolean allowCancel, long startupDelay)
title
- Title for progress dialog.initLabel
- Initial text of label.minBar
- Minimum value for progress bar.maxBar
- Maximum value for progress bar.allowCancel
- Display a cancel button. public ProgressDialog(java.lang.String title, java.lang.String initLabel, int minBar, int maxBar, boolean allowCancel)
title
- Title for progress dialog.initLabel
- Initial text of label.minBar
- Minimum value for progress bar.maxBar
- Maximum value for progress bar.allowCancel
- Display a cancel button. public ProgressDialog(java.awt.Window parentWindow, java.lang.String title, java.lang.String initLabel, int minBar, int maxBar, boolean allowCancel)
parentWindow
- The parent window.title
- Title for progress dialog.initLabel
- Initial text of label.minBar
- Minimum value for progress bar.maxBar
- Maximum value for progress bar.allowCancel
- Display a cancel button. Method Detail |
---|
public void setTitle(java.lang.String title)
setTitle
in interface ProgressReporter
setTitle
in class java.awt.Dialog
title
- The title. protected void doCancel()
Override this in derived subclasses to take a specified action when the cancel button is pressed. The only required action is to set the class variable "cancelled" to true.
public boolean isCancelled()
isCancelled
in interface ProgressReporter
public void setStartupTime(long startupTime)
setStartupTime
in interface ProgressReporter
startupTime
- The startup time in milliseconds. public void updateProgress(int barValue, java.lang.String newLabel)
updateProgress
in interface ProgressReporter
barValue
- New value for progress bar.
If negative, the current value remains unchanged.newLabel
- New label text. If null, the current
label text is unchanged. public void updateProgress(int barValue)
updateProgress
in interface ProgressReporter
barValue
- New value for progress bar. public void updateProgress(java.lang.String newLabel)
updateProgress
in interface ProgressReporter
newLabel
- New label text. If null, the current
label text is unchanged. public void setLabelColor(java.awt.Color color)
setLabelColor
in interface ProgressReporter
color
- Text color for progress label. public void setMaximumBarValue(int maxBar)
setMaximumBarValue
in interface ProgressReporter
maxBar
- The new maximum bar value. public int getCurrentBarValue()
getCurrentBarValue
in interface ProgressReporter
public int getMaximumBarValue()
getMaximumBarValue
in interface ProgressReporter
public void setIndeterminate(boolean isIndeterminate)
setIndeterminate
in interface ProgressReporter
isIndeterminate
- true if indeterminate, false otherwise. public void makeVisible(boolean visible)
makeVisible
in interface ProgressReporter
visible
- true to show dialog, false to hide. public void close()
close
in interface ProgressReporter
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |