|
|||||||||
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 javax.swing.JComponent javax.swing.JPanel edu.northwestern.at.utils.swing.ProgressPanel
public class ProgressPanel
Displays progress in a panel.
The progress panel an updateable label field for
explaining the current progress of the task and a progress bar
for visually displaying the current progress of the task.
This is essentially the same as a ProgressDialog
but the
ProgressPanel can be embedded in another panel or window.
A progress panel supports but does not provide a cancel button. You may create a cancel button externally and invoke the progress panel's "doCancel" method as the button press action. Override the "doCancel" method to add any processing you need for a cancel action.
The progress panel is updated twice a second using a timer. This ensures correct behavior regardless of the originating thread.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JPanel |
---|
javax.swing.JPanel.AccessibleJPanel |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
javax.swing.JComponent.AccessibleJComponent |
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 panel 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 javax.swing.JLabel |
label
Label for explanatory message. |
protected java.awt.Color |
labelColor
The label color. |
protected java.lang.String |
labelText
The current value of the 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 boolean |
nowIndeterminate
True if the progress display is indeterminate. |
protected boolean |
nowVisible
True if the progress display is visible. |
static int |
ONE_SECOND
One second in thousandths of a second. |
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. |
protected javax.swing.Timer |
timer
The timer used to update the display a one second intervals. |
protected javax.swing.JLabel |
titleLabel
Title. |
protected java.lang.String |
titleText
The current value of the title. |
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
ProgressPanel(java.lang.String title,
java.lang.String initLabel)
Create progress panel with specified title and initial label. |
|
ProgressPanel(java.lang.String title,
java.lang.String initLabel,
int minBar,
int maxBar,
long startupDelay)
Create progress panel. |
Method Summary | |
---|---|
void |
close()
Close. |
protected void |
doCancel()
Action to take when cancel button pressed. |
protected void |
doClose()
Action to take when panel closed. |
java.awt.event.ActionListener |
getCancelPressedAction()
Return cancel action listener. |
int |
getCurrentBarValue()
Get the current bar value. |
int |
getMaximumBarValue()
Get the maximum bar value. |
boolean |
isCancelled()
See if progress panel 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 newBarValue)
Update progress display. |
void |
updateProgress(int newBarValue,
java.lang.String newLabelText)
Update progress display. |
void |
updateProgress(java.lang.String newLabelText)
Update progress display. |
protected void |
updateProgressDisplay()
Updates the progress display. |
Methods inherited from class javax.swing.JPanel |
---|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
Methods inherited from class javax.swing.JComponent |
---|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update |
Methods inherited from class java.awt.Container |
---|
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, 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, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, 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 titleLabel
protected java.lang.String titleText
protected javax.swing.JLabel label
protected java.lang.String labelText
protected java.awt.Color labelColor
protected javax.swing.JProgressBar progressBar
protected int currentBarValue
protected boolean cancelled
protected static long defaultStartupDelay
protected long startupDelay
protected long startupTime
protected int labelWidth
protected boolean nowVisible
protected boolean nowIndeterminate
protected javax.swing.Timer timer
public static final int ONE_SECOND
protected java.awt.event.ActionListener cancelPressed
Constructor Detail |
---|
public ProgressPanel(java.lang.String title, java.lang.String initLabel, int minBar, int maxBar, long startupDelay)
title
- Title for progress display.initLabel
- Initial text of label.minBar
- Minimum value for progress bar.maxBar
- Maximum value for progress bar.startupDelay
- Startup delay. Dialog will not appear
until this many milliseconds have passed
since creation of dialog. public ProgressPanel(java.lang.String title, java.lang.String initLabel)
title
- Title for progress display.initLabel
- Initial text of label. Method Detail |
---|
public void setTitle(java.lang.String title)
setTitle
in interface ProgressReporter
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 java.awt.event.ActionListener getCancelPressedAction()
Use to create a cancel button externally.
protected void doClose()
Override this in derived subclasses to take a specified action when the panel is closed.
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 newBarValue, java.lang.String newLabelText)
updateProgress
in interface ProgressReporter
newBarValue
- New value for progress bar.
If negative, the current value remains
unchanged.newLabelText
- New label text. If null, the current
label text is unchanged. public void updateProgress(int newBarValue)
updateProgress
in interface ProgressReporter
newBarValue
- New value for progress bar. public void updateProgress(java.lang.String newLabelText)
updateProgress
in interface ProgressReporter
newLabelText
- 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
protected void updateProgressDisplay()
UpdateProgress is guaranteed to run on the AWT event thread since it is called from the timer's actionPerformed handler method.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |