JIDE 3.5.15

com.jidesoft.status
Class ProgressStatusBarItem

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 com.jidesoft.swing.NullPanel
                      extended by com.jidesoft.status.StatusBarItem
                          extended by com.jidesoft.status.ProgressStatusBarItem
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class ProgressStatusBarItem
extends StatusBarItem

ProgressStatusBarItem is the main one that can display the status. The reason it is called ProgressStatusBarItem is because it can also have a progress bar in it which only shows in running mode. See below. The second one is in a running mode.

ProgressStatusBarItem's item name is "Status". We hardcoded inside this class. So if you add it to StatusBar and want to get it, you just call statusBar.getItemByName("Status"). If you want to change it to something else, you would have to override getItemName method.

The width of ProgressStatusBarItem is predefined as 200 by overriding getPreferredSize(). If you want a different behavior, please also override the method.

See Also:
Serialized Form

Nested Class Summary
static interface ProgressStatusBarItem.CancelCallback
          A callback for the progress fields cancel button.
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
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
 JidePopup _popup
           
 
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
ProgressStatusBarItem()
          Default constructor.
 
Method Summary
 void clearHistory()
           
protected  AbstractButton createCancelButton()
          Creates the cancel button.
protected  JProgressBar createProgressBar()
          Creates the progress bar.
protected  JLabel createProgressLabel()
          Creates the progress label.
protected  Component createStatusPanel()
          Creates a new status panel.
 AbstractButton getCancelButton()
          Gets tne cancel button instance.
 ProgressStatusBarItem.CancelCallback getCancelCallback()
          Gets the action of the cancel button.
 String getCancelText()
          Gets the text used by cancel button.
 String getDefaultStatus()
          Sets default status.
 String getItemName()
          Gets item name.
 int getMaxNumberOfHistoryItems()
          Gets the maximum number of items kept in history list.
 Dimension getPreferredSize()
          If the preferredSize has been set to a non-null value just returns it.
 JProgressBar getProgressBar()
          Gets the progress bar instance.
 JLabel getProgressLabel()
          Gets the progress label instance.
 JLabel getStatusLabel()
          Gets the status label.
 void setCancelCallback(ProgressStatusBarItem.CancelCallback callback)
          Sets the action when the cancel button is clicked.
 void setCancelText(String cancelText)
          Sets the text used by cancel button.
 void setDefaultStatus(String defaultStatus)
          Sets default status.
 void setIndeterminate(boolean indeterminate)
          Sets the process bar indeterminated.
 void setMaxNumberOfHistoryItems(int maxNumberOfHistoryItems)
          Sets the maximum number of items kept in history list.
 void setPreferredWidth(int width)
          Deprecated. please override #getPreferredSize to change the preferred width
 void setProgress(int percent)
          Sets progress percentage.
 void setProgressBarWidth(int width)
          Set the maximum width of the progress bar.
 void setProgressIcon(Icon icon)
          Sets status icon when progress bar is visible.
 void setProgressStatus(String message)
          Sets status message when progress bar is visible.
 void setStatus(String status)
          Sets status to be displayed on the status bar item.
 void setStatusIcon(Icon icon)
          Sets status icon to be displayed on the status bar item.
 void showProgress()
          ProgressStatusBarItem holds two panels.
 void showStatus()
          ProgressStatusBarItem holds two panels.
protected  void statusChanged(String status)
           
 
Methods inherited from class com.jidesoft.status.StatusBarItem
getPreferredWidth, updateUI
 
Methods inherited from class com.jidesoft.swing.NullPanel
setBackground, setFont, setForeground
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI
 
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, 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, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, 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

_popup

public JidePopup _popup
Constructor Detail

ProgressStatusBarItem

public ProgressStatusBarItem()
Default constructor.

Method Detail

showStatus

public void showStatus()
ProgressStatusBarItem holds two panels. One panel is used to display a static status message. The other panel is used to display a progress bar and its message. They are added to a CardLayout. Depending on which method is called, corresponding panel will be shown. For example. if you call setStatus(), showStatus() will be called automatically. So usually you don't need to call this method unless you only need to force the display of the status panel.

See Also:
showProgress()

showProgress

public void showProgress()
ProgressStatusBarItem holds two panels. One panel is used to display a static status message. The other panel is used to display a progress bar and its message. They are added to a CardLayout. Depending on which method is called, corresponding panel will be shown. For example. if you call setProgressStatus() or setProgress(), showProgress() will be called automatically. So usually you don't need to call this method unless you only need to force the display of the progress panel.

See Also:
showStatus()

createProgressLabel

protected JLabel createProgressLabel()
Creates the progress label. By default, it will be an instance of NullLabel.

Returns:
a new JLabel.

createProgressBar

protected JProgressBar createProgressBar()
Creates the progress bar.

Returns:
a new progress bar.

setPreferredWidth

@Deprecated
public void setPreferredWidth(int width)
Deprecated. please override #getPreferredSize to change the preferred width

Set preferred width of this component.

Overrides:
setPreferredWidth in class StatusBarItem
Parameters:
width - the width

createCancelButton

protected AbstractButton createCancelButton()
Creates the cancel button. User can override this method to provide their own cancel button.

Returns:
the cancel button.

createStatusPanel

protected Component createStatusPanel()
Creates a new status panel. By default it will be an instance of NullLabel.

Returns:
a new status panel.

setStatus

public void setStatus(String status)
Sets status to be displayed on the status bar item.

This method will spawn a thread to do the updating if the calling thread is not event dispatching thread. So you don't need to use SwingUtilities.invokeLater(Runnable) in your code to call this method.

Parameters:
status - the new status

statusChanged

protected void statusChanged(String status)

clearHistory

public void clearHistory()

setStatusIcon

public void setStatusIcon(Icon icon)
Sets status icon to be displayed on the status bar item. This icon will appear before the status text.

This method will spawn a thread to do the updating if the calling thread is not event dispatching thread. So you don't need to use SwingUtilities.invokeLater(Runnable) in your code to call this method.

Parameters:
icon - new status icon

setProgressStatus

public void setProgressStatus(String message)
Sets status message when progress bar is visible.

This method will spawn a thread to do the updating if the calling thread is not event dispatching thread. So you don't need to use SwingUtilities.invokeLater(Runnable) in your code to call this method.

Parameters:
message - status before the progress bar

setProgressIcon

public void setProgressIcon(Icon icon)
Sets status icon when progress bar is visible.

This method will spawn a thread to do the updating if the calling thread is not event dispatching thread. So you don't need to use SwingUtilities.invokeLater(Runnable) in your code to call this method.

Parameters:
icon - the icon before the progress status

setProgress

public void setProgress(int percent)
Sets progress percentage. When percent equals to 100, showStatus() method will be called and the default status will be shown.

This method will spawn a thread to do the updating if the calling thread is not event dispatching thread. So you don't need to use SwingUtilities.invokeLater(Runnable) in your code to call this method.

Parameters:
percent - From 0 to 100.

setCancelCallback

public void setCancelCallback(ProgressStatusBarItem.CancelCallback callback)
Sets the action when the cancel button is clicked.

Parameters:
callback - A callback. if null, Cancel button will be set invisiable.

getCancelCallback

public ProgressStatusBarItem.CancelCallback getCancelCallback()
Gets the action of the cancel button.

Returns:
the callback.

getDefaultStatus

public String getDefaultStatus()
Sets default status. The status will be shown if the process ends normally.

Note: In the future, the default status will be automatically used if user is in idle mode

Returns:
default status

setDefaultStatus

public void setDefaultStatus(String defaultStatus)
Sets default status. Default status can be used if a progress ends

Parameters:
defaultStatus - the default status such as "Ready".

getItemName

public String getItemName()
Description copied from class: StatusBarItem
Gets item name.

Specified by:
getItemName in class StatusBarItem
Returns:
item name

getCancelText

public String getCancelText()
Gets the text used by cancel button.

Returns:
text on cancel button

setCancelText

public void setCancelText(String cancelText)
Sets the text used by cancel button.

Parameters:
cancelText - new text on cancel button

getPreferredSize

public Dimension getPreferredSize()
If the preferredSize has been set to a non-null value just returns it. If the UI delegate's getPreferredSize method returns a non null value then return that; otherwise defer to the component's layout manager.

Overrides:
getPreferredSize in class StatusBarItem
Returns:
the value of the preferredSize property
See Also:
JComponent.setPreferredSize(java.awt.Dimension), ComponentUI

setIndeterminate

public void setIndeterminate(boolean indeterminate)
Sets the process bar indeterminated.

Parameters:
indeterminate - true or false.

setProgressBarWidth

public void setProgressBarWidth(int width)
Set the maximum width of the progress bar.

Parameters:
width - the maximum width of the progress bar.

getProgressBar

public JProgressBar getProgressBar()
Gets the progress bar instance.

Returns:
the progress bar instance.

getCancelButton

public AbstractButton getCancelButton()
Gets tne cancel button instance.

Returns:
the cancel button instance.

getProgressLabel

public JLabel getProgressLabel()
Gets the progress label instance. The label appears before the progress bar when the status bar is in progress mode.

Returns:
the progress label.

getStatusLabel

public JLabel getStatusLabel()
Gets the status label. The label appears when status bar is in status mode (opposite to progress mode).

Returns:
the status label.

getMaxNumberOfHistoryItems

public int getMaxNumberOfHistoryItems()
Gets the maximum number of items kept in history list.

Returns:
the maximum number of items kept in history list.

setMaxNumberOfHistoryItems

public void setMaxNumberOfHistoryItems(int maxNumberOfHistoryItems)
Sets the maximum number of items kept in history list. If you set it to -1, it means no limit. If you set to 0, it means no history will be kept thus it won't show a drop down list when clicking on the status label.

Parameters:
maxNumberOfHistoryItems - the maximum number of items kept in history list.

JIDE 3.5.15