ehsbe CommonsTM
Version 1.1.0rc3

com.ehsbe.commons.gui
Class JxStatusBar

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by org.jdesktop.swingx.JXStatusBar
                  extended by com.ehsbe.commons.gui.JxStatusBar
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable

public class JxStatusBar
extends org.jdesktop.swingx.JXStatusBar

A pre-defined statusbar, which already has the usually required components: messaget text panel, progressbar, animated label. It makes the update of those components easy/threadsafe wrt. proper event routing to the EDT, if necessary.

Version:
$Revision: 498 $
Author:
Jens Elkner
See Also:
StatusTask, Serialized Form

Nested Class Summary
protected  class JxStatusBar.Updater
          Simple helper to avoid boiler plate code - call one of the update* methods.
 
Nested classes/interfaces inherited from class org.jdesktop.swingx.JXStatusBar
org.jdesktop.swingx.JXStatusBar.Constraint
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static int BUSY_ANIMRATE
          default duration in milliseconds a single animation image is shown
static int MSG_TIMEOUT
          default duration in milliseconds a message gets displayed in the message panel
 
Fields inherited from class org.jdesktop.swingx.JXStatusBar
uiClassID
 
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
JxStatusBar()
          Create a statusbar, which contains a label for messages, a progressbar as well as an animated label.
 
Method Summary
protected  void adjustPreferredSize()
          Helps to avoid "jumping" statusbar height by getting the max height over all available components and setting the preferred height of this statusbar to the calculated max height incl. insets.
 void clear()
          Remove all workers from the internal task queue as well as all 'out-of-bands' messages for the internal message queue and update the state of the corresponding components.
 void close()
          Cleanup up all timers and resources, so that the application may terminate cleanly without having any statusbar relatated threads running, which would prevent it from exiting.
 long getDefaultAnimationTimeout()
          Get the duration a sprite is displayed in an animation.
protected  JLabel getMessageLabel()
          Get the component in use for displaying messages.
 int getMessageTimeout()
          Gets the default timeout aka max duration a message gets displayed in the statusbar.
protected  com.ehsbe.commons.gui.JxStatusBar.Msg getNextMessage(boolean removeExpired)
          Get the next 'out-of-bands' none-expired message from the message queue.
protected  JProgressBar getProgressbar()
          Get the progressbar which displays the current worker's progress state.
 void push(StatusTask<?,?> worker)
          Add the worker to the task monitor list of this statusbar.
 void push(String txt)
          Display this "out-of-bounds" message.
 void push(String txt, int duration)
          Display this "out-of-bounds" message for the given time.
 void push(String txt, int duration, Level level)
          Display this "out-of-bounds" message for the given time decorated according to the given type.
 void setDefaultAnimationTimeout(long millis)
          Set the duration a sprite should be displayed in an animation.
 void setMessageTimeout(int millis)
          Sets the default timeout aka max duration a message gets displayed in the statusbar.
protected  void update(String src)
          Convinience method: calls updateProgress(String) and updateMessage(String) in this order.
protected  void updateMessage(String src)
          Update the state of the message label wrt. the head of the message and task queue.
protected  void updateProgress(String src)
          Update the state of the animation label and progress bar wrt. the head of the task queue.
 
Methods inherited from class org.jdesktop.swingx.JXStatusBar
getAddSeparators, getUI, getUIClassID, isResizeHandleEnabled, setAddSeparators, setResizeHandleEnabled, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, 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, paramString, 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

MSG_TIMEOUT

public static final int MSG_TIMEOUT
default duration in milliseconds a message gets displayed in the message panel

See Also:
Constant Field Values

BUSY_ANIMRATE

public static final int BUSY_ANIMRATE
default duration in milliseconds a single animation image is shown

See Also:
Constant Field Values
Constructor Detail

JxStatusBar

public JxStatusBar()
Create a statusbar, which contains a label for messages, a progressbar as well as an animated label.

Method Detail

setMessageTimeout

public void setMessageTimeout(int millis)
Sets the default timeout aka max duration a message gets displayed in the statusbar. Gets applied immediately to the currently running timer, and all subsequently submitted out of bound messages.

Parameters:
millis - time in milliseconds

getMessageTimeout

public int getMessageTimeout()
Gets the default timeout aka max duration a message gets displayed in the statusbar.

Returns:
time in milliseconds.

push

public void push(StatusTask<?,?> worker)
Add the worker to the task monitor list of this statusbar.

Parameters:
worker - a worker in SwingWorker.StateValue.PENDING or SwingWorker.StateValue.STARTED state. All others (canceled or done) are ignored.

push

public void push(String txt)
Display this "out-of-bounds" message.

Parameters:
txt - text to display.
See Also:
push(String, int), push(String, int, Level)

push

public void push(String txt,
                 int duration)
Display this "out-of-bounds" message for the given time.

Parameters:
txt - text to display.
duration - how long it should be displayed.
See Also:
push(String, int, Level)

push

public void push(String txt,
                 int duration,
                 Level level)
Display this "out-of-bounds" message for the given time decorated according to the given type.

Parameters:
txt - text to display. Ignored if null.
duration - how long it should be displayed. If it is < 50, the default timeout will be used instead.
level - decoration type. If null, Level.INFO will be used instead.

getNextMessage

protected com.ehsbe.commons.gui.JxStatusBar.Msg getNextMessage(boolean removeExpired)
Get the next 'out-of-bands' none-expired message from the message queue. All expired messages are popped from the queue before the result gets returned.

Parameters:
removeExpired - if true remove all expired timers from the head of the queue
Returns:
null if the queue is empty, the head of the queue otherwise.

updateProgress

protected void updateProgress(String src)
Update the state of the animation label and progress bar wrt. the head of the task queue. Make sure, that it is called in the EDT, only!

Parameters:
src - the name of the sender of the event (used in debug messages, only)

updateMessage

protected void updateMessage(String src)
Update the state of the message label wrt. the head of the message and task queue. Message in the message queue have always a higher priority (out-of-bands messages) than the ones from the task queue. Make sure, that it is called in the EDT, only!

Parameters:
src - the name of the sender of the event (used in debug messages, only)

getMessageLabel

protected JLabel getMessageLabel()
Get the component in use for displaying messages.

Returns:
the massage component in use.

getProgressbar

protected JProgressBar getProgressbar()
Get the progressbar which displays the current worker's progress state.

Returns:
the progressbar in use.

update

protected void update(String src)
Convinience method: calls updateProgress(String) and updateMessage(String) in this order.

Parameters:
src - the name of the sender of the event (used in debug messages, only)

adjustPreferredSize

protected void adjustPreferredSize()
Helps to avoid "jumping" statusbar height by getting the max height over all available components and setting the preferred height of this statusbar to the calculated max height incl. insets. So, before calling this method, all components should be populated in such a way, that they have its max. height. After that they can be reset to the dessired state.


setDefaultAnimationTimeout

public void setDefaultAnimationTimeout(long millis)
Set the duration a sprite should be displayed in an animation.

Parameters:
millis - time in milliseconds to set.

getDefaultAnimationTimeout

public long getDefaultAnimationTimeout()
Get the duration a sprite is displayed in an animation.

Returns:
the timeout in milliseconds.

clear

public void clear()
Remove all workers from the internal task queue as well as all 'out-of-bands' messages for the internal message queue and update the state of the corresponding components.


close

public void close()
Cleanup up all timers and resources, so that the application may terminate cleanly without having any statusbar relatated threads running, which would prevent it from exiting. Once this method has been called, this instance should not be used anymore, since it will not function correctly anymore.


ehsbe CommonsTM
Version 1.1.0rc3

Copyright ©2005-2009 EHSBE, Walther-Rathenau-Str. 58, 39104 Magdeburg, Sachsen-Anhalt, Germany. All Rights Reserved.