uic.widgets
Class StatusBar

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by uic.widgets.StatusBar
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable

public class StatusBar
extends JComponent

This widget draws a StatusBar with progress line and cancel button. Normal usage of a statusBar is on a Window, which MainWindow will help you with.

Since:
1.2
See Also:
Serialized Form

Nested Class Summary
static interface StatusBar.StatusLabelInterface
          For applications that want more then just a single label on their status bar they can use this.
 
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.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  String backup
           
protected  AbstractButton cancelButton
           
protected  JProgressBar progressBar
           
protected  String statusText
           
 
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
StatusBar()
          Sole constructor.
 
Method Summary
 AbstractButton addProgressBar(int maxValue, boolean allowCancelButton)
          Create a progressbar on the statusBar with an optional cancel button.
 void clearTemporaryStatusText()
          Reset temporary text.
protected  StatusBar.StatusLabelInterface createStatusLabel()
          The major part of the statusbar is occupied by the statusLabel, this method creates it.
 Dimension getPreferredSize()
          overrides the size from the super
 void paintComponent(Graphics g)
          Overrides the paint from the super
 void removeProgressBar()
          Remove the progress bar from the statusbar.
 void setProgress(int value)
          Update an existing progressbar to the new value.
static void setStatus(Component you, String text)
          Set the statusbar on a window which belongs to the same window as 'you' do.
 void setTemporaryStatusText(String text)
          set a status text that is just a temprorary indicator.
 void setText(String text)
          Set the status text to be displayed on this statusbar.
 
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, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, 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, updateUI
 
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

statusText

protected String statusText

backup

protected String backup

progressBar

protected JProgressBar progressBar

cancelButton

protected AbstractButton cancelButton
Constructor Detail

StatusBar

public StatusBar()
Sole constructor.

Method Detail

createStatusLabel

protected StatusBar.StatusLabelInterface createStatusLabel()
The major part of the statusbar is occupied by the statusLabel, this method creates it. This method returns the StatusLabel inner class which provides 1 label and nothing more.


addProgressBar

public AbstractButton addProgressBar(int maxValue,
                                     boolean allowCancelButton)
Create a progressbar on the statusBar with an optional cancel button. For long operations it is good to show progress made, after calling this method the progress will be shown.

Parameters:
maxValue - the maximum value, when set using setProgress will show the progress completely full.
allowCancelButton - create a cancel button next to the progress bar.
Returns:
the cancel button (when requested) so for event handling.
See Also:
removeProgressBar(), setProgress(int)

removeProgressBar

public void removeProgressBar()
Remove the progress bar from the statusbar.

See Also:
addProgressBar(int, boolean), setProgress(int)

setProgress

public void setProgress(int value)
Update an existing progressbar to the new value.

See Also:
removeProgressBar(), addProgressBar(int, boolean)

paintComponent

public void paintComponent(Graphics g)
Overrides the paint from the super

Overrides:
paintComponent in class JComponent

getPreferredSize

public Dimension getPreferredSize()
overrides the size from the super

Overrides:
getPreferredSize in class JComponent

setStatus

public static void setStatus(Component you,
                             String text)
Set the statusbar on a window which belongs to the same window as 'you' do. This is a static method that allows you to set the status on a statusbar without actually having an instance of that statusbar, or the containing MainWindow.

Parameters:
you - is a component that is positioned on the same Window as the statusbar.
text - the new text to be displayed.
Throws:
IllegalArgumentException - if 'you' is not placed on a window which is a MainWindow.
See Also:
MainWindow

setText

public void setText(String text)
Set the status text to be displayed on this statusbar.


setTemporaryStatusText

public void setTemporaryStatusText(String text)
set a status text that is just a temprorary indicator. If you have a long running task changes are that there is a text in the statusbar for that function, maybe even a progress bar next to it. During that long-running process the user might go over the menu and get a help text in the statusbar. This is a temporary text as the text from the long running process should re-appear when the mouse leaves the menus.

See Also:
setText(String), clearTemporaryStatusText()

clearTemporaryStatusText

public void clearTemporaryStatusText()
Reset temporary text.

See Also:
setTemporaryStatusText(String)


Copyright © 2002-2004 Thomas Zander Available under the Free Apache licence