org.japura.gui
Class CollapsiblePanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by org.japura.gui.CollapsiblePanel
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class CollapsiblePanel
extends javax.swing.JComponent

Copyright (C) 2008-2010 Carlos Eduardo Leite de Andrade

This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this program. If not, see www.gnu.org/licenses/

For more information, contact: www.japura.org

Author:
Carlos Eduardo Leite de Andrade
See Also:
Serialized Form

Nested Class Summary
 
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
 
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
CollapsiblePanel()
           
CollapsiblePanel(javax.swing.Icon icon, java.lang.String title)
           
CollapsiblePanel(javax.swing.Icon icon, java.lang.String title, javax.swing.JComponent[] extraButtons)
           
CollapsiblePanel(java.lang.String title)
           
CollapsiblePanel(java.lang.String title, javax.swing.JComponent[] extraButtons)
           
 
Method Summary
 java.awt.Component add(java.awt.Component comp)
           
 java.awt.Component add(java.awt.Component comp, int index)
           
 void add(java.awt.Component comp, java.lang.Object constraints)
           
 void add(java.awt.Component comp, java.lang.Object constraints, int index)
           
 java.awt.Component add(java.lang.String name, java.awt.Component comp)
           
 void addCollapsiblePanelListener(CollapsiblePanelListener listener)
           
 void collapse()
          Collapse this panel.
 void collapseImmediately()
           
 void doLayout()
           
 void expand()
          Expand this panel.
 void expandImmediately()
           
static java.lang.Object getDefaultTitleBackground()
           
 java.awt.Font getFont()
           
 java.awt.Dimension getPreferredSize()
           
protected  java.awt.Dimension getPreferredSize(boolean collapsed)
           
 java.awt.Color getSeparatorColor()
           
 int getSpeed()
           
 java.lang.Object getTitleBackground()
           
 java.awt.Color getTitleForeground()
           
 int getTitleMargin()
           
 boolean hasTitleBackgroundGradient()
           
 void invalidate()
           
 boolean isAnimationEnabled()
          Determines whether the animation is enabled.
 boolean isCollapsed()
          Determines whether the panel is collapsed.
 boolean isCollapsing()
          Determines whether the panel is collapsing.
 boolean isExpanded()
          Determines whether the panel is expanded.
 boolean isExpanding()
          Determines whether the panel is expanding.
 boolean isInAction()
          Determines whether the panel is expanding or collapsing.
 boolean isLockEnabled()
           
protected  void paintBorder(java.awt.Graphics g)
           
protected  void paintComponent(java.awt.Graphics g)
           
 void remove(java.awt.Component arg0)
           
 void remove(int arg0)
           
 void removeAll()
           
 void removeCollapsiblePanelListener(CollapsiblePanelListener listener)
           
 void removeExtraButtons()
           
 void removeIcon()
           
 void setAnimationEnabled(boolean animationEnabled)
           
static void setDefaultBlackIcons()
           
static void setDefaultCollapseIcon(javax.swing.Icon icon)
           
static void setDefaultExpandIcon(javax.swing.Icon icon)
           
static void setDefaultTitleBackground(java.awt.Color color)
           
static void setDefaultTitleBackground(Gradient gradient)
           
static void setDefaultWhiteIcons()
           
 void setExtraButtons(javax.swing.JComponent[] extraButtons)
           
 void setFont(java.awt.Font font)
           
 void setIcon(javax.swing.Icon icon)
           
 void setIcons(javax.swing.Icon iconUp, javax.swing.Icon iconDown)
           
 void setLockEnabled(boolean enabled)
          Sets whether or not this collapse or expand option's of component is enabled.
 void setSeparatorColor(java.awt.Color separatorColor)
           
 void setSeparatorThickness(int thickness)
          Creates a separator line border between title and view with the specified width.
 void setSpeed(int speed)
           
 void setTitle(java.lang.String title)
           
 void setTitleBackground(java.awt.Color color)
           
 void setTitleBackground(Gradient gradient)
           
 void setTitleForeground(java.awt.Color color)
           
 void setTitleMargin(int titleMargin)
           
 
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, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, 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, 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
addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, 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, 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
 

Constructor Detail

CollapsiblePanel

public CollapsiblePanel()

CollapsiblePanel

public CollapsiblePanel(java.lang.String title)

CollapsiblePanel

public CollapsiblePanel(javax.swing.Icon icon,
                        java.lang.String title)

CollapsiblePanel

public CollapsiblePanel(java.lang.String title,
                        javax.swing.JComponent[] extraButtons)

CollapsiblePanel

public CollapsiblePanel(javax.swing.Icon icon,
                        java.lang.String title,
                        javax.swing.JComponent[] extraButtons)
Method Detail

removeExtraButtons

public void removeExtraButtons()

setExtraButtons

public void setExtraButtons(javax.swing.JComponent[] extraButtons)

doLayout

public void doLayout()
Overrides:
doLayout in class java.awt.Container

paintComponent

protected void paintComponent(java.awt.Graphics g)
Overrides:
paintComponent in class javax.swing.JComponent

paintBorder

protected final void paintBorder(java.awt.Graphics g)
Overrides:
paintBorder in class javax.swing.JComponent

getPreferredSize

public final java.awt.Dimension getPreferredSize()
Overrides:
getPreferredSize in class javax.swing.JComponent

getPreferredSize

protected java.awt.Dimension getPreferredSize(boolean collapsed)

removeIcon

public void removeIcon()

setIcon

public void setIcon(javax.swing.Icon icon)

setSeparatorThickness

public void setSeparatorThickness(int thickness)
Creates a separator line border between title and view with the specified width.

Parameters:
thickness - an integer specifying the width in pixels

isCollapsed

public boolean isCollapsed()
Determines whether the panel is collapsed.

Returns:
true if the panel is collapsed, false otherwise
See Also:
isCollapsing(), collapse(), collapseImmediately()

isCollapsing

public boolean isCollapsing()
Determines whether the panel is collapsing.

Returns:
true if the panel is collapsing, false otherwise
See Also:
isCollapsed(), collapse(), collapseImmediately()

isExpanded

public boolean isExpanded()
Determines whether the panel is expanded.

Returns:
true if the panel is expanded, false otherwise
See Also:
isExpanding(), expand(), expandImmediately()

isExpanding

public boolean isExpanding()
Determines whether the panel is expanding.

Returns:
true if the panel is expanding, false otherwise
See Also:
isExpanded(), expand(), expandImmediately()

isAnimationEnabled

public boolean isAnimationEnabled()
Determines whether the animation is enabled. Animation is enabled initially by default. The animation may be enabled or disabled by calling its setAnimationEnabled method.

Returns:
true if the animation is enabled, false otherwise
See Also:
setAnimationEnabled(boolean)

setAnimationEnabled

public void setAnimationEnabled(boolean animationEnabled)

setSpeed

public void setSpeed(int speed)

getSpeed

public int getSpeed()

remove

public void remove(java.awt.Component arg0)
Overrides:
remove in class java.awt.Container

remove

public void remove(int arg0)
Overrides:
remove in class java.awt.Container

removeAll

public void removeAll()
Overrides:
removeAll in class java.awt.Container

add

public java.awt.Component add(java.awt.Component comp,
                              int index)
Overrides:
add in class java.awt.Container

add

public void add(java.awt.Component comp,
                java.lang.Object constraints,
                int index)
Overrides:
add in class java.awt.Container

add

public void add(java.awt.Component comp,
                java.lang.Object constraints)
Overrides:
add in class java.awt.Container

add

public java.awt.Component add(java.awt.Component comp)
Overrides:
add in class java.awt.Container

add

public java.awt.Component add(java.lang.String name,
                              java.awt.Component comp)
Overrides:
add in class java.awt.Container

isLockEnabled

public boolean isLockEnabled()

setLockEnabled

public void setLockEnabled(boolean enabled)
Sets whether or not this collapse or expand option's of component is enabled.

Parameters:
enabled - true if these options should be enabled, false otherwise
See Also:
isLockEnabled()

collapseImmediately

public void collapseImmediately()

collapse

public void collapse()
Collapse this panel. This method will have no effect if the panel already be expanding, locked or collapsed.

See Also:
collapseImmediately(), setAnimationEnabled(boolean), isAnimationEnabled()

expandImmediately

public void expandImmediately()

expand

public void expand()
Expand this panel. This method will have no effect if the panel already be collapsing, locked or expanded.

See Also:
expandImmediately(), setAnimationEnabled(boolean), isAnimationEnabled()

getSeparatorColor

public java.awt.Color getSeparatorColor()

setSeparatorColor

public void setSeparatorColor(java.awt.Color separatorColor)

getFont

public java.awt.Font getFont()
Specified by:
getFont in interface java.awt.MenuContainer
Overrides:
getFont in class java.awt.Component

setFont

public void setFont(java.awt.Font font)
Overrides:
setFont in class javax.swing.JComponent

setTitle

public void setTitle(java.lang.String title)

setTitleForeground

public void setTitleForeground(java.awt.Color color)

getTitleForeground

public java.awt.Color getTitleForeground()

setTitleBackground

public void setTitleBackground(java.awt.Color color)

setTitleBackground

public void setTitleBackground(Gradient gradient)

getTitleBackground

public java.lang.Object getTitleBackground()

hasTitleBackgroundGradient

public boolean hasTitleBackgroundGradient()

getTitleMargin

public int getTitleMargin()

setTitleMargin

public void setTitleMargin(int titleMargin)

setIcons

public void setIcons(javax.swing.Icon iconUp,
                     javax.swing.Icon iconDown)

addCollapsiblePanelListener

public void addCollapsiblePanelListener(CollapsiblePanelListener listener)

removeCollapsiblePanelListener

public void removeCollapsiblePanelListener(CollapsiblePanelListener listener)

isInAction

public boolean isInAction()
Determines whether the panel is expanding or collapsing.

Returns:
true if the panel is expanding or collapsing, false otherwise

invalidate

public void invalidate()
Overrides:
invalidate in class java.awt.Container

setDefaultExpandIcon

public static void setDefaultExpandIcon(javax.swing.Icon icon)

setDefaultCollapseIcon

public static void setDefaultCollapseIcon(javax.swing.Icon icon)

setDefaultBlackIcons

public static void setDefaultBlackIcons()

setDefaultWhiteIcons

public static void setDefaultWhiteIcons()

getDefaultTitleBackground

public static java.lang.Object getDefaultTitleBackground()

setDefaultTitleBackground

public static void setDefaultTitleBackground(java.awt.Color color)

setDefaultTitleBackground

public static void setDefaultTitleBackground(Gradient gradient)