at.tuwien.ifs.commons.gui.controls
Class TitledCollapsiblePanel

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 at.tuwien.ifs.commons.gui.controls.TitledCollapsiblePanel
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible
Direct Known Subclasses:
AbstractViewerControl

public class TitledCollapsiblePanel
extends JPanel

This component combines a JXCollapsiblePane with a clickable title bar to toggle between collapsed and expanded state.

The methods add(Component), add(Component, Object), remove(Component), remove(int), removeAll() delegate to JXCollapsiblePane.

Use setTitle(String), setIcon(Icon), setIconTitleGap(int), setContentBackground(Color), setContentBorder(Border), setTitleBackground(Color) and setTitleBorder(Border) so set the appearence.

Use setCollapsed(boolean) to collapse/expand the contentPane.

Version:
$Id: TitledCollapsiblePanel.java 3888 2010-11-02 17:42:53Z frank $
Author:
Jakob Frank
See Also:
JXCollapsiblePane, JXTitledPanel, Serialized Form

Nested Class Summary
static class TitledCollapsiblePanel.Orientation
           
private  class TitledCollapsiblePanel.TitleRow
           
 
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
private  org.jdesktop.swingx.JXCollapsiblePane contentCollapser
           
private  Container contentContainer
           
private  TitledCollapsiblePanel.Orientation orientation
           
private static long serialVersionUID
           
private  TitledCollapsiblePanel.TitleRow title
           
 
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
TitledCollapsiblePanel()
           
TitledCollapsiblePanel(LayoutManager layout)
           
TitledCollapsiblePanel(String title)
           
TitledCollapsiblePanel(String title, boolean collapsed)
           
TitledCollapsiblePanel(String title, CommonSOMViewerStateData state, LayoutManager layout)
           
TitledCollapsiblePanel(String title, LayoutManager layout)
           
TitledCollapsiblePanel(String title, LayoutManager layout, boolean collapsed)
           
 
Method Summary
 Component add(Component comp)
           
 Component add(Component comp, int index)
           
 void add(Component comp, Object constraints)
           
 void add(Component comp, Object constraints, int index)
           
 Component add(String name, Component comp)
           
 Color getContentBackground()
           
 Border getContentBorder()
           
 Container getContentPane()
           
 int getDecoratorPadding()
           
 int getHorizontalTitleAlignment()
           
 int getHorizontalTitleTextPosition()
           
 Icon getIcon()
           
 int getIconTitleGap()
           
 LayoutManager getLayout()
           
 TitledCollapsiblePanel.Orientation getOrientation()
           
 Dimension getPreferredSize()
          Do not override this method.
 boolean getShowTitleDecoration()
          see getShowTitleDecoration()
 String getTitle()
           
 Color getTitleBackground()
           
 Border getTitleBorder()
           
private  void init()
           
private  void initContent()
           
private  void initTitle()
           
 boolean isAnimated()
           
 boolean isCollapsed()
           
 void pack()
          Deprecated. 
 void remove(Component comp)
           
 void remove(int index)
           
 void removeAll()
           
 void setAnimated(boolean animated)
           
 void setCollapsed(boolean val)
           
 void setContentBackground(Color bg)
           
 void setContentBorder(Border border)
           
 void setContentPane(Container contentPane)
           
 void setDecoratorPadding(int decoratorPadding)
           
 void setHorizontalTitleAlignment(int alignment)
           
 void setHorizontalTitleTextPosition(int textPosition)
           
 void setIcon(Icon defaultIcon)
           
 void setIconTitleGap(int iconTextGap)
           
 void setLayout(LayoutManager mgr)
           
 void setOrientation(TitledCollapsiblePanel.Orientation orientation)
           
 void setShowTitleDecoration(boolean show)
          The title decoration is the expand/collapse icon in the top right corner of the title.
 void setTitle(String title)
           
 void setTitleBackground(Color bg)
           
 void setTitleBorder(Border border)
           
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
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, 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
 
Methods inherited from class java.awt.Container
addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

orientation

private TitledCollapsiblePanel.Orientation orientation

title

private final TitledCollapsiblePanel.TitleRow title

contentCollapser

private final org.jdesktop.swingx.JXCollapsiblePane contentCollapser

contentContainer

private Container contentContainer
Constructor Detail

TitledCollapsiblePanel

public TitledCollapsiblePanel()

TitledCollapsiblePanel

public TitledCollapsiblePanel(String title)

TitledCollapsiblePanel

public TitledCollapsiblePanel(LayoutManager layout)

TitledCollapsiblePanel

public TitledCollapsiblePanel(String title,
                              CommonSOMViewerStateData state,
                              LayoutManager layout)

TitledCollapsiblePanel

public TitledCollapsiblePanel(String title,
                              LayoutManager layout)

TitledCollapsiblePanel

public TitledCollapsiblePanel(String title,
                              boolean collapsed)

TitledCollapsiblePanel

public TitledCollapsiblePanel(String title,
                              LayoutManager layout,
                              boolean collapsed)
Method Detail

getDecoratorPadding

public int getDecoratorPadding()

setDecoratorPadding

public void setDecoratorPadding(int decoratorPadding)

add

public Component add(Component comp)
Overrides:
add in class Container

add

public void add(Component comp,
                Object constraints)
Overrides:
add in class Container

add

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

add

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

add

public Component add(String name,
                     Component comp)
Overrides:
add in class Container

getHorizontalTitleAlignment

public int getHorizontalTitleAlignment()

getHorizontalTitleTextPosition

public int getHorizontalTitleTextPosition()

getIcon

public Icon getIcon()

getIconTitleGap

public int getIconTitleGap()

getLayout

public LayoutManager getLayout()
Overrides:
getLayout in class Container

getTitle

public String getTitle()

init

private void init()

initContent

private void initContent()

initTitle

private void initTitle()

setContentBackground

public void setContentBackground(Color bg)

setHorizontalTitleAlignment

public void setHorizontalTitleAlignment(int alignment)

setHorizontalTitleTextPosition

public void setHorizontalTitleTextPosition(int textPosition)

setIcon

public void setIcon(Icon defaultIcon)

setIconTitleGap

public void setIconTitleGap(int iconTextGap)

setLayout

public void setLayout(LayoutManager mgr)
Overrides:
setLayout in class Container

setTitle

public void setTitle(String title)

setTitleBackground

public void setTitleBackground(Color bg)

setTitleBorder

public void setTitleBorder(Border border)

getTitleBorder

public Border getTitleBorder()

getTitleBackground

public Color getTitleBackground()

setShowTitleDecoration

public void setShowTitleDecoration(boolean show)
The title decoration is the expand/collapse icon in the top right corner of the title.


getShowTitleDecoration

public boolean getShowTitleDecoration()
see getShowTitleDecoration()


getContentBackground

public Color getContentBackground()

getContentBorder

public Border getContentBorder()

getContentPane

public Container getContentPane()

setContentPane

public void setContentPane(Container contentPane)

remove

public void remove(Component comp)
Overrides:
remove in class Container

remove

public void remove(int index)
Overrides:
remove in class Container

removeAll

public void removeAll()
Overrides:
removeAll in class Container

setContentBorder

public void setContentBorder(Border border)

isAnimated

public boolean isAnimated()
Returns:
true if the pane is animated, false otherwise
See Also:
JXCollapsiblePane.isAnimated()

isCollapsed

public boolean isCollapsed()
Returns:
true if the pane is collapsed, false if expanded
See Also:
JXCollapsiblePane.isCollapsed()

setAnimated

public void setAnimated(boolean animated)
See Also:
JXCollapsiblePane.setAnimated(boolean)

setCollapsed

public void setCollapsed(boolean val)
See Also:
JXCollapsiblePane.setCollapsed(boolean)

setOrientation

public void setOrientation(TitledCollapsiblePanel.Orientation orientation)

getOrientation

public TitledCollapsiblePanel.Orientation getOrientation()

pack

@Deprecated
public void pack()
Deprecated. 


getPreferredSize

public final Dimension getPreferredSize()
Do not override this method. Use JComponent.setPreferredSize(Dimension) if necessary!

Overrides:
getPreferredSize in class JComponent
See Also:
JComponent.getPreferredSize()