org.formaria.swing
Class RollupBar

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 org.formaria.swing.Panel
                      extended by org.formaria.swing.RollupBar
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, CompositeComponent, PersistentState
Direct Known Subclasses:
Accordian

public class RollupBar
extends Panel
implements java.awt.event.ActionListener, CompositeComponent

An outlook style roll-up bar. The methods are modelled on the JTabbedPane

Copyright (c) Formaria Ltd., 2008, This software is licensed under the GNU Public License (GPL), please see license.txt for more details. If you make commercial use of this software you must purchase a commercial license from formaria.

$Revision: 1.15 $

See Also:
Serialized Form

Nested Class Summary
 class RollupBar.AccordianLayout
           
 
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
protected  boolean allExpandable
           
protected  boolean antiAlias
           
protected  java.lang.String buttonClassName
           
protected  javax.swing.ButtonGroup buttonGroup
           
protected  int buttonHeight
           
protected  Project currentProject
           
protected  int lastSelIdx
           
protected  int maxPanelSize
           
protected  int minPanelSize
           
protected  int selIdx
           
protected  javax.swing.JToggleButton topBtn
           
 
Fields inherited from class org.formaria.swing.Panel
arc, BORDER_BEVEL, BORDER_FLAT, BORDER_NONE, drawBorder, padding, translucent, usesLaf
 
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
RollupBar()
          Create a new button panel
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Invoked when a mouse button has been pressed on a component.
 java.awt.Component add(java.awt.Component comp)
          Add a new button.
 void add(java.awt.Component comp, java.lang.Object constraints)
          Add a new button.
 java.awt.Color getBackgroundAt(int index)
          Get a button's background color
 javax.swing.JToggleButton getButton(int index)
          Get the button component at the specified index, skips over the expanded panel
 int getButtonCount()
          Get the number of buttons
 java.awt.Component getContentComponent(int idx)
          Get a nested component
 int getContentComponentCount()
          Get the count of the nested components
 java.awt.Color getForegroundAt(int index)
          Get a button's foreground color
 java.awt.Dimension getMaximumSize()
          Get the minimum layout size of this component
 int getMaxSharedPanels()
          Get the maximum number of shared panels
 java.awt.Dimension getMinimumSize()
          Get the minimum layout size of this component
 java.awt.Dimension getPreferredSize()
          Get the preferred layout size of this component
 int getSelectedIndex()
          Get the index of the selected button
 java.lang.String getTitleAt(int index)
          Get the title of the button at the specified index
protected  boolean isAllExpandable()
          Does this component allow all of its panel to be visible at once?
 boolean isOverlapButtons()
          Do the buttons overlap for the adjacent panels when the content is hidden?
 void setAlignment(int align)
          Set one or more attributes of the component.
protected  void setAllExpandable(boolean state)
          Set this component to allow all of its panel to be visible at once.
 void setAntiAlias(boolean value)
          Set the anti-alias property
 void setAntiAlias(java.lang.String state)
          Set the AntiAliasing state.
 void setBackgroundAt(int index, java.awt.Color clr)
          Set the button background color
 void setButtonHeight(int value)
          Set teh height of the rollup buttons
 void setDisabledImageName(java.lang.String imgName)
          Sets the disabled image to display based on the image name.
 void setDragEnabled(boolean state)
          Enabled drag and drop operations
 void setForegroundAt(int index, java.awt.Color clr)
          Set the foreground color
 void setIconName(java.lang.String value)
           
 void setImageName(java.lang.String imgName)
          Sets the image to display based on the image name.
 void setMaxSharedPanels(int maxPanels)
          Set the maximum number of shared panels (the number of panels that can occupy a single divider)
 void setOverlapButtons(boolean state)
          Set the buttons to overlap for the adjacent panels when the content is hidden
 void setPainter(java.lang.String value)
          Set the painter for the buttons
 void setPressedImageName(java.lang.String imgName)
          Sets the pressed image to display based on the image name.
 void setRolloverImageName(java.lang.String imgName)
          Sets the rollover image to display based on the image name.
 void setSelectedIndex(int index)
          Select a button
 void setSlideImages(boolean value)
          Slide images of the content or just collapse
 void setState(java.lang.String[] panelStates)
           
 void setStyle(java.lang.String value)
          Set the style for the buttons
 void setTitleAt(int index, java.lang.String str)
          Set a button's title
 void setVertical(boolean vertical)
          Set the layout as vertical (one button above another)
 
Methods inherited from class org.formaria.swing.Panel
addNotify, getArc, getDrawBorder, getInsets, getPainter, getUsesLaf, paintComponent, restoreState, saveState, setArc, setBlend, setBorder, setBounds, setDrawBorder, setPad, setSwingBorder, setTitle, setTitlePos, setTitlePosition, setTitleStyle, setToolTip, setTranslucent, setUsesLaf, update
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, 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, getListeners, getLocation, 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, 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
 
Methods inherited from class java.awt.Container
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, 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

selIdx

protected int selIdx

lastSelIdx

protected int lastSelIdx

topBtn

protected javax.swing.JToggleButton topBtn

buttonGroup

protected javax.swing.ButtonGroup buttonGroup

currentProject

protected Project currentProject

buttonHeight

protected int buttonHeight

minPanelSize

protected int minPanelSize

maxPanelSize

protected int maxPanelSize

antiAlias

protected boolean antiAlias

buttonClassName

protected java.lang.String buttonClassName

allExpandable

protected boolean allExpandable
Constructor Detail

RollupBar

public RollupBar()
Create a new button panel

Method Detail

add

public java.awt.Component add(java.awt.Component comp)
Add a new button. The add method could not be overloaded so this method adds does the equivalent.

Overrides:
add in class java.awt.Container
Parameters:
comp - the new button component
Returns:
the new component

add

public void add(java.awt.Component comp,
                java.lang.Object constraints)
Add a new button. The add method could not be overloaded so this method adds does the equivalent.

Overrides:
add in class java.awt.Container
Parameters:
comp - the new button component

getButton

public javax.swing.JToggleButton getButton(int index)
Get the button component at the specified index, skips over the expanded panel

Parameters:
index - the button index
Returns:
the button component

getBackgroundAt

public java.awt.Color getBackgroundAt(int index)
Get a button's background color

Parameters:
index - the button index
Returns:
the color

getForegroundAt

public java.awt.Color getForegroundAt(int index)
Get a button's foreground color

Parameters:
index - the button index
Returns:
the color

getButtonCount

public int getButtonCount()
Get the number of buttons

Returns:
the number of buttons

getSelectedIndex

public int getSelectedIndex()
Get the index of the selected button

Returns:
the selection index

getTitleAt

public java.lang.String getTitleAt(int index)
Get the title of the button at the specified index

Parameters:
index - the button index
Returns:
the button text/title

setBackgroundAt

public void setBackgroundAt(int index,
                            java.awt.Color clr)
Set the button background color

Parameters:
index - the button index
clr - the new colr

setForegroundAt

public void setForegroundAt(int index,
                            java.awt.Color clr)
Set the foreground color

Parameters:
index - the button index
clr - the new color

setSelectedIndex

public void setSelectedIndex(int index)
Select a button

Parameters:
index - the button index

setTitleAt

public void setTitleAt(int index,
                       java.lang.String str)
Set a button's title

Parameters:
index - the button index
str - the text for the button

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Invoked when a mouse button has been pressed on a component.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
e - the event

setSlideImages

public void setSlideImages(boolean value)
Slide images of the content or just collapse

Parameters:
value - true to slide an image of teh content

setDragEnabled

public void setDragEnabled(boolean state)
Enabled drag and drop operations

Parameters:
state - true to enable

setButtonHeight

public void setButtonHeight(int value)
Set teh height of the rollup buttons

Parameters:
value - the height in pixels

setAntiAlias

public void setAntiAlias(boolean value)
Set the anti-alias property

Parameters:
value - thew new value

setStyle

public void setStyle(java.lang.String value)
Set the style for the buttons

Parameters:
value - the new style

setPainter

public void setPainter(java.lang.String value)
Set the painter for the buttons

Overrides:
setPainter in class Panel
Parameters:
value - the new painter class

setIconName

public void setIconName(java.lang.String value)
Parameters:
value -

setAlignment

public void setAlignment(int align)
Set one or more attributes of the component. Attributes include
align (left|right|center ) or
alignment (left|right|center )
buffered (true|false) double buffering

Parameters:
align - 1 to right align the text, 0 for left alignment and 2 for centered text

setImageName

public void setImageName(java.lang.String imgName)
Sets the image to display based on the image name.

Overrides:
setImageName in class Panel
Parameters:
imgName - the image

setPressedImageName

public void setPressedImageName(java.lang.String imgName)
Sets the pressed image to display based on the image name.

Parameters:
imgName - the image

setRolloverImageName

public void setRolloverImageName(java.lang.String imgName)
Sets the rollover image to display based on the image name.

Parameters:
imgName - the image

setDisabledImageName

public void setDisabledImageName(java.lang.String imgName)
Sets the disabled image to display based on the image name.

Parameters:
imgName - the image

setAntiAlias

public void setAntiAlias(java.lang.String state)
Set the AntiAliasing state. Any buttons contained within the rolloup bar will have their antialias setting modified by this call.

Parameters:
"true" - to anti alias the text

isAllExpandable

protected boolean isAllExpandable()
Does this component allow all of its panel to be visible at once?

Returns:
true if all panels can be made visible

setAllExpandable

protected void setAllExpandable(boolean state)
Set this component to allow all of its panel to be visible at once.

Parameters:
allExpandable -

getContentComponentCount

public int getContentComponentCount()
Get the count of the nested components

Specified by:
getContentComponentCount in interface CompositeComponent
Returns:
the component count

getContentComponent

public java.awt.Component getContentComponent(int idx)
Get a nested component

Specified by:
getContentComponent in interface CompositeComponent
Parameters:
the - index of the nested component
Returns:
the specified component

setVertical

public void setVertical(boolean vertical)
Set the layout as vertical (one button above another)

Parameters:
isVertical -

isOverlapButtons

public boolean isOverlapButtons()
Do the buttons overlap for the adjacent panels when the content is hidden?

Returns:
true if the buttons ovrlap

setOverlapButtons

public void setOverlapButtons(boolean state)
Set the buttons to overlap for the adjacent panels when the content is hidden

Parameters:
state - the new flag value

getMaxSharedPanels

public int getMaxSharedPanels()
Get the maximum number of shared panels

Returns:
the panel count

setMaxSharedPanels

public void setMaxSharedPanels(int maxPanels)
Set the maximum number of shared panels (the number of panels that can occupy a single divider)

Parameters:
maxPanels - the new max panel count

setState

public void setState(java.lang.String[] panelStates)

getPreferredSize

public java.awt.Dimension getPreferredSize()
Get the preferred layout size of this component

Overrides:
getPreferredSize in class Panel
Returns:
the preferred size

getMinimumSize

public java.awt.Dimension getMinimumSize()
Get the minimum layout size of this component

Overrides:
getMinimumSize in class javax.swing.JComponent
Returns:
the preferred size

getMaximumSize

public java.awt.Dimension getMaximumSize()
Get the minimum layout size of this component

Overrides:
getMaximumSize in class javax.swing.JComponent
Returns:
the preferred size