qflib 0.98.0

de.qfs.lib.gui
Class StatusLine

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--de.qfs.lib.gui.StatusLine
All Implemented Interfaces:
CountListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class StatusLine
extends javax.swing.JComponent
implements CountListener

The StatusLine is a component that is typically placed at the bottom of a Frame and used to display status and other messages.

The StatusLine is built from a simple JComponent with a BorderLayout, containing one JLabel in the center, so it can easily be extended to display additional information.

These are some common uses for a status line:

These are supported with setPermanentMessage, pushMessage and setTemporaryMessage.

The status line will be redrawn immediately after changing the message, since standard AWT redraw during idle time is typically too late.

New since qflib version 0.96.0 is support for a progress bar which can be displayed with showProgressBar and turned off with removeProgressBar. The progress value can be set with setProgressValue. Alternatively StatusLine now implements the CountListener interface and can be registered with a CountingInputStream.

Version:
$Revision: 1.14 $
Author:
Gregor Schmid
See Also:
Serialized Form

Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
protected  javax.swing.JLabel message
          The Label displaying the messages.
protected  javax.swing.JProgressBar progress
          Optional progress bar.
protected  boolean progressShowing
          Whether the progress bar is currently shown.
protected  boolean showPercent
          Whether to display a percent string in the progress bar.
 
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
StatusLine()
          Create a new StatusLine.
 
Method Summary
 void countChanged(CountEvent event)
          Notify the progress bar of a new value.
 void forceUpdate()
          Force redraw of StatusLine
 javax.swing.JLabel getMessageLabel()
          Get the JLabel component that displays the status message.
 javax.swing.JProgressBar getProgressBar()
          Get the progress bar of the status line.
protected  void init()
          Initialize the StatusLine.
 boolean isProgressShowing()
          Query whther the progess bar is currently showing.
 void popMessage()
          Remove the semi permanent message set with pushMessage and display the permanent message.
 void pushMessage(java.lang.String msg)
          Display a message until it is either removed with popMessage or replaced with another call to pushMessage.
 void removeProgressBar()
          Remove the progress bar from the StatusLine.
 void setPermanentMessage(java.lang.String msg)
          Set the message to display in the StatusLine whenever no other message is displayed.
 void setProgressValue(int value)
          Set the value for the progress bar and force a redisplay of the StatusLine.
 void setTemporaryMessage(java.lang.String msg)
          Display a message temporarily.
 void setTemporaryMessageDelay(int delay)
          Set the delay in milliseconds after which to replace the temporary message with the previous message.
 void showProgressBar(int min, int max, java.lang.String where, boolean showPercent)
          Display a progress bar.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getUIClassID, getVerifyInputWhenFocusTarget, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, hide, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processFocusEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

message

protected javax.swing.JLabel message
The Label displaying the messages.

progress

protected javax.swing.JProgressBar progress
Optional progress bar.
Since:
0.96.0

progressShowing

protected boolean progressShowing
Whether the progress bar is currently shown.
Since:
0.96.0

showPercent

protected boolean showPercent
Whether to display a percent string in the progress bar.
Since:
0.96.0
Constructor Detail

StatusLine

public StatusLine()
Create a new StatusLine.
Method Detail

init

protected void init()
Initialize the StatusLine. This method uses a BorderLayout with the message Label at the center. It can be replaced or extended to create a customized StatusLine.

getMessageLabel

public final javax.swing.JLabel getMessageLabel()
Get the JLabel component that displays the status message.
Returns:
The StatusLine's message label.

setPermanentMessage

public void setPermanentMessage(java.lang.String msg)
Set the message to display in the StatusLine whenever no other message is displayed. The display is updated only, if the permanent message is the active one.
Parameters:
msg - The permanent message to set.

pushMessage

public void pushMessage(java.lang.String msg)
Display a message until it is either removed with popMessage or replaced with another call to pushMessage.
Parameters:
msg - The message to display.

popMessage

public void popMessage()
Remove the semi permanent message set with pushMessage and display the permanent message.

setTemporaryMessage

public void setTemporaryMessage(java.lang.String msg)
Display a message temporarily. After a delay it will be replaced with the previous message.
Parameters:
msg - The message to display.

setTemporaryMessageDelay

public void setTemporaryMessageDelay(int delay)
Set the delay in milliseconds after which to replace the temporary message with the previous message. Default is 1500 ms.
Parameters:
delay - The delay to set.

forceUpdate

public void forceUpdate()
Force redraw of StatusLine
Since:
0.96.0

showProgressBar

public void showProgressBar(int min,
                            int max,
                            java.lang.String where,
                            boolean showPercent)
Display a progress bar.
Parameters:
min - Minimum value for the progress bar.
max - Maximum value for the progress bar.
where - BorderLayout constraint, e.g. "West".
showPercent - Whether to display a percent string inside the progress bar.
Since:
0.96.0

removeProgressBar

public void removeProgressBar()
Remove the progress bar from the StatusLine.
Since:
0.96.0

setProgressValue

public void setProgressValue(int value)
Set the value for the progress bar and force a redisplay of the StatusLine.
Parameters:
value - The new value.
Since:
0.96.0

countChanged

public void countChanged(CountEvent event)
Notify the progress bar of a new value.
Specified by:
countChanged in interface CountListener
Parameters:
event - The event containing the details.
Since:
0.96.0

getProgressBar

public javax.swing.JProgressBar getProgressBar()
Get the progress bar of the status line.
Returns:
The status line's progress bar.
Since:
0.98.0

isProgressShowing

public boolean isProgressShowing()
Query whther the progess bar is currently showing.
Returns:
True if the progess bar is showing.
Since:
0.98.0

qflib 0.98.0