Copyright 2012-02-25 Werner Randelshofer

ch.randelshofer.gui
Class GlassPaneProgressView

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by ch.randelshofer.gui.GlassPaneProgressView
All Implemented Interfaces:
ProgressObserver, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public class GlassPaneProgressView
extends javax.swing.JPanel
implements ProgressObserver

A class to monitor the progress of some operation.

Version:
1.7 2011-07-22 Adds disposeOnClose property.
1.6.1 2007-12-04 Added missing constructor.
1.6 2007-11-19 Upgraded to new ProgressObserver interface.
1.5 2006-09-18 Interface ProgressObserver implemented
1.4.1 2004-12-23 Use invokeAndWait in method setCancelable instead of invokeLater.
1.4 2004-04-19 Reworked to have a BoundedRangeModel as the data model.
1.2 2002-12-23 Operation getProgress() added.
1.1 2002-07-28 ScrollPane in class GlassPaneProgressView added.
1.0 2002-05-10 Created.
Author:
Werner Randelshofer
See Also:
Serialized Form

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
 
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
GlassPaneProgressView(java.lang.String message, java.lang.String note)
          Creates a new indeterminate GlassPaneProgressView.
GlassPaneProgressView(java.lang.String message, java.lang.String note, boolean isIndeterminate)
          Creates a new GlassPaneProgressView.
GlassPaneProgressView(java.lang.String message, java.lang.String note, int min, int max)
          Creates a new GlassPaneProgressView.
GlassPaneProgressView(java.lang.String message, java.lang.String note, int min, int max, boolean isIndeterminate)
          Creates a new GlassPaneProgressView.
 
Method Summary
 void cancel()
          Cancels the operation.
 void close()
          Closes the progress view.
 void complete()
          Indicate that the operation is complete.
 java.lang.String getError()
          Specifies the error message that is displayed along with the progress message.
 int getMaximum()
          Returns the maximum value -- the higher end of the progress value.
 int getMinimum()
          Returns the minimum value -- the lower end of the progress value.
 javax.swing.BoundedRangeModel getModel()
           
 java.lang.String getNote()
          Specifies the additional note that is displayed along with the progress message.
 int getProgress()
          Returns the progress of the operation being monitored.
 java.lang.String getWarning()
          Specifies the warning message that is displayed along with the progress message.
 boolean isCanceled()
          Returns true if the user has hit the Cancel button in the progress dialog.
 boolean isClosed()
          Returns true if the progress view is closed.
 boolean isCompleted()
          Returns true if the operation is completed.
 boolean isDisposeOnClose()
           
 boolean isIndeterminate()
          Returns true if the progress observer is set to indeterminate.
 void setCancelable(boolean b)
          Set cancelable to false if the operation can not be canceled.
 void setDisposeOnClose(boolean newValue)
           
 void setDoCancel(java.lang.Runnable doCancel)
          The specified Runnable is executed when the user presses the cancel button.
 void setError(java.lang.String message)
          Specifies the additional error message that is displayed along with the progress message.
 void setIndeterminate(boolean newValue)
          Sets the progress observer to indeterminate.
 void setMaximum(int m)
          Specifies the maximum value.
 void setMinimum(int m)
          Specifies the minimum value.
 void setModel(javax.swing.BoundedRangeModel brm)
           
 void setNote(java.lang.String note)
          Specifies the additional note that is displayed along with the progress message.
 void setProgress(int nv)
          Indicate the progress of the operation being monitored.
 void setWarning(java.lang.String message)
          Specifies the additional warning message that is displayed along with the progress message.
 
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
 

Constructor Detail

GlassPaneProgressView

public GlassPaneProgressView(java.lang.String message,
                             java.lang.String note,
                             boolean isIndeterminate)
Creates a new GlassPaneProgressView.


GlassPaneProgressView

public GlassPaneProgressView(java.lang.String message,
                             java.lang.String note,
                             int min,
                             int max)
Creates a new GlassPaneProgressView.


GlassPaneProgressView

public GlassPaneProgressView(java.lang.String message,
                             java.lang.String note,
                             int min,
                             int max,
                             boolean isIndeterminate)
Creates a new GlassPaneProgressView.


GlassPaneProgressView

public GlassPaneProgressView(java.lang.String message,
                             java.lang.String note)
Creates a new indeterminate GlassPaneProgressView.

Method Detail

setModel

public void setModel(javax.swing.BoundedRangeModel brm)
Specified by:
setModel in interface ProgressObserver

getModel

public javax.swing.BoundedRangeModel getModel()
Specified by:
getModel in interface ProgressObserver

setCancelable

public void setCancelable(boolean b)
Set cancelable to false if the operation can not be canceled.

Specified by:
setCancelable in interface ProgressObserver

setDoCancel

public void setDoCancel(java.lang.Runnable doCancel)
The specified Runnable is executed when the user presses the cancel button.

Specified by:
setDoCancel in interface ProgressObserver

setProgress

public void setProgress(int nv)
Indicate the progress of the operation being monitored. If the specified value is >= the maximum, the progress monitor is closed.

Specified by:
setProgress in interface ProgressObserver
Parameters:
nv - an int specifying the current value, between the maximum and minimum specified for this component
See Also:
setMinimum(int), setMaximum(int), close()

getProgress

public int getProgress()
Returns the progress of the operation being monitored.

Specified by:
getProgress in interface ProgressObserver

complete

public void complete()
Indicate that the operation is complete. This happens automatically when the value set by setProgress is >= max, but it may be called earlier if the operation ends early.

Specified by:
complete in interface ProgressObserver

close

public void close()
Closes the progress view.

Specified by:
close in interface ProgressObserver

getMinimum

public int getMinimum()
Returns the minimum value -- the lower end of the progress value.

Specified by:
getMinimum in interface ProgressObserver
Returns:
an int representing the minimum value
See Also:
setMinimum(int)

setMinimum

public void setMinimum(int m)
Specifies the minimum value.

Specified by:
setMinimum in interface ProgressObserver
Parameters:
m - an int specifying the minimum value
See Also:
getMinimum()

getMaximum

public int getMaximum()
Returns the maximum value -- the higher end of the progress value.

Specified by:
getMaximum in interface ProgressObserver
Returns:
an int representing the maximum value
See Also:
setMaximum(int)

setMaximum

public void setMaximum(int m)
Specifies the maximum value.

Specified by:
setMaximum in interface ProgressObserver
Parameters:
m - an int specifying the maximum value
See Also:
getMaximum()

isCanceled

public boolean isCanceled()
Returns true if the user has hit the Cancel button in the progress dialog.

Specified by:
isCanceled in interface ProgressObserver

isCompleted

public boolean isCompleted()
Returns true if the operation is completed.

Specified by:
isCompleted in interface ProgressObserver

isClosed

public boolean isClosed()
Returns true if the progress view is closed.

Specified by:
isClosed in interface ProgressObserver

cancel

public void cancel()
Cancels the operation. This method must be invoked from the user event dispatch thread.

Specified by:
cancel in interface ProgressObserver

setNote

public void setNote(java.lang.String note)
Specifies the additional note that is displayed along with the progress message. Used, for example, to show which file the is currently being copied during a multiple-file copy.

Specified by:
setNote in interface ProgressObserver
Parameters:
note - a String specifying the note to display
See Also:
getNote()

getNote

public java.lang.String getNote()
Specifies the additional note that is displayed along with the progress message.

Specified by:
getNote in interface ProgressObserver
Returns:
a String specifying the note to display
See Also:
setNote(java.lang.String)

setWarning

public void setWarning(java.lang.String message)
Description copied from interface: ProgressObserver
Specifies the additional warning message that is displayed along with the progress message. Used, for example, to show which files couldn't be copied during a multiple-file copy..

Specified by:
setWarning in interface ProgressObserver
Parameters:
message - a String specifying the message to display, or null if there is no warning.
See Also:
ProgressObserver.getWarning()

getWarning

public java.lang.String getWarning()
Description copied from interface: ProgressObserver
Specifies the warning message that is displayed along with the progress message.

Specified by:
getWarning in interface ProgressObserver
Returns:
a String specifying the message to display, or null if there is no warning.

setError

public void setError(java.lang.String message)
Description copied from interface: ProgressObserver
Specifies the additional error message that is displayed along with the progress message. Used, for example, to show which files couldn't be copied during a multiple-file copy..

Specified by:
setError in interface ProgressObserver
Parameters:
message - a String specifying the message to display, or null if there is no error.
See Also:
ProgressObserver.getWarning()

getError

public java.lang.String getError()
Description copied from interface: ProgressObserver
Specifies the error message that is displayed along with the progress message.

Specified by:
getError in interface ProgressObserver
Returns:
a String specifying the message to display, or null if there is no error.

setIndeterminate

public void setIndeterminate(boolean newValue)
Description copied from interface: ProgressObserver
Sets the progress observer to indeterminate.

Specified by:
setIndeterminate in interface ProgressObserver

isIndeterminate

public boolean isIndeterminate()
Description copied from interface: ProgressObserver
Returns true if the progress observer is set to indeterminate.

Specified by:
isIndeterminate in interface ProgressObserver

isDisposeOnClose

public boolean isDisposeOnClose()

setDisposeOnClose

public void setDisposeOnClose(boolean newValue)

Copyright 2012-02-25 Werner Randelshofer