be.ugent.caagt.swirl.subwindows
Class Subwindow

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by be.ugent.caagt.swirl.subwindows.Subwindow
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class Subwindow
extends javax.swing.JComponent

Wraps a child component into a small `window' with a title bar. Clicking on this title bar collapses the component: the child component is hidden and only the title bar is still visible. Clicking again, resets the subwindow to its full size.

For best effect, subwindows of this kind should be stacked in a container which uses a vertical box layout, as in the folllowing example

      Subwindow subwindow1 = new Subwindow(component1, true);
      Subwindow subwindow2 = new Subwindow(component2, false);

      JPanel container = new JPanel ();
      container.setLayout(new BoxLayout (container, BoxLayout.Y_AXIS));
      container.add (subwindow1);
      container.add (subwindow2);
      container.add (Box.createVerticalGlue());
      container.setBackground(Color.WHITE);
 

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
Subwindow(javax.swing.JComponent child, boolean collapsed)
          Create a new subwindow which displays the given child component.The name of the child conmoponent is used as the caption of the title bar of this window.
 
Method Summary
 void addSubwindowListener(SubwindowListener listener)
          Register a listener which will be notified of all changes in the collapsed state of the subwindow.
 void doLayout()
           
 javax.swing.JComponent getChildComponent()
          Return the child component which is managed by this subwindow.
 int getHorizontalWindowPadding()
          Horizontal padding for this subwindow.
 java.awt.Dimension getMaximumSize()
          The maximum size is derived from the maximum size of the child unless it has been explicitely set.
 java.awt.Dimension getMinimumSize()
          The minimum size is derived from the minimum size of the child unless it has been explicitely set.
 java.awt.Dimension getPreferredSize()
          The preferred size is derived from the preferred size of the child unless it has been explicitely set.
 java.awt.Color getTitleBarBorderColor()
          The color of the subwindow border, as set by the user.
 java.awt.Color getTitleBarColor()
          The color of the title bar.
 java.awt.Color getTitleBarColorNoFocus()
          The color of the title bar when the subwindow does not own the focus, as set by the user.
 int getTitleBarHeight()
          The height of the title bar in pixels.
 java.awt.Color getTitleBarTextColor()
          Return the color for the text of the title bar.
 java.awt.Color getTitleBarTextColorNoFocus()
          The color of the text in the title bar when the subwindow does not own the focus, as set by the user.
 int getVerticalWindowPadding()
          Vertical padding for this subwindow.
 boolean isCollapsed()
          Is this window collapsed?
 void paintComponent(java.awt.Graphics g)
           
 void removeSubwindowListener(SubwindowListener listener)
          Undo the registration of the given listener as a subwindow listener.
 void setCollapsed(boolean collapsed)
          Change the 'collapsed' state of this window.
 void setHorizontalWindowPadding(int horizontalWindowPadding)
          Sets the horizontal for this subwindow.
 void setTitleBarBorderColor(java.awt.Color titleBarBorderColor)
          Set the color to be used for the subwindow border.
 void setTitleBarColor(java.awt.Color titleBarColor)
          Set the color to be used for the title bar.
 void setTitleBarColorNoFocus(java.awt.Color titleBarColorNoFocus)
          Set the color to be used for the title bar when the subwindow does not own the focus.
 void setTitleBarHeight(int titleBarHeight)
          Set the height of the title bar.
 void setTitleBarTextColor(java.awt.Color titleBarTextColor)
          Set the color to be used for the text in the title bar.
 void setTitleBarTextColorNoFocus(java.awt.Color titleBarTextColorNoFocus)
          Set the color to be used for the text in the title bar when the subwindow does not own the focus.
 void setVerticalWindowPadding(int verticalWindowPadding)
          Sets the vertical for this subwindow.
 void toggleCollapsed()
          Toggle the 'collapsed' state of this window.
 
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, 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, 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, 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
 

Constructor Detail

Subwindow

public Subwindow(javax.swing.JComponent child,
                 boolean collapsed)
Create a new subwindow which displays the given child component.The name of the child conmoponent is used as the caption of the title bar of this window.

Method Detail

getChildComponent

public javax.swing.JComponent getChildComponent()
Return the child component which is managed by this subwindow. The name of the child component is used as the caption of the title bar.


isCollapsed

public boolean isCollapsed()
Is this window collapsed?


setCollapsed

public void setCollapsed(boolean collapsed)
Change the 'collapsed' state of this window.


toggleCollapsed

public void toggleCollapsed()
Toggle the 'collapsed' state of this window.


getTitleBarColor

public java.awt.Color getTitleBarColor()
The color of the title bar.


getTitleBarColorNoFocus

public java.awt.Color getTitleBarColorNoFocus()
The color of the title bar when the subwindow does not own the focus, as set by the user.

Returns:
null when the user did not explicitely set this color

setTitleBarColor

public void setTitleBarColor(java.awt.Color titleBarColor)
Set the color to be used for the title bar. Defaults to gray.


setTitleBarColorNoFocus

public void setTitleBarColorNoFocus(java.awt.Color titleBarColorNoFocus)
Set the color to be used for the title bar when the subwindow does not own the focus. Defaults to a paler version of the title bar color.


getTitleBarTextColor

public java.awt.Color getTitleBarTextColor()
Return the color for the text of the title bar.


setTitleBarTextColor

public void setTitleBarTextColor(java.awt.Color titleBarTextColor)
Set the color to be used for the text in the title bar. Defaults to white


setTitleBarTextColorNoFocus

public void setTitleBarTextColorNoFocus(java.awt.Color titleBarTextColorNoFocus)
Set the color to be used for the text in the title bar when the subwindow does not own the focus. Defaults to the title bar text color.


getTitleBarTextColorNoFocus

public java.awt.Color getTitleBarTextColorNoFocus()
The color of the text in the title bar when the subwindow does not own the focus, as set by the user.

Returns:
null when the user did not explicitely set this color

setTitleBarBorderColor

public void setTitleBarBorderColor(java.awt.Color titleBarBorderColor)
Set the color to be used for the subwindow border. Defaults to the title bar color.


getTitleBarBorderColor

public java.awt.Color getTitleBarBorderColor()
The color of the subwindow border, as set by the user.

Returns:
null when the user did not explicitely set this color

getTitleBarHeight

public int getTitleBarHeight()
The height of the title bar in pixels.


setTitleBarHeight

public void setTitleBarHeight(int titleBarHeight)
Set the height of the title bar.


getHorizontalWindowPadding

public int getHorizontalWindowPadding()
Horizontal padding for this subwindow.


setHorizontalWindowPadding

public void setHorizontalWindowPadding(int horizontalWindowPadding)
Sets the horizontal for this subwindow.


getVerticalWindowPadding

public int getVerticalWindowPadding()
Vertical padding for this subwindow.


setVerticalWindowPadding

public void setVerticalWindowPadding(int verticalWindowPadding)
Sets the vertical for this subwindow.


paintComponent

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

getPreferredSize

public java.awt.Dimension getPreferredSize()
The preferred size is derived from the preferred size of the child unless it has been explicitely set. For a collapsed window, only the preferred width of the child component is taken into account.

Overrides:
getPreferredSize in class javax.swing.JComponent

getMinimumSize

public java.awt.Dimension getMinimumSize()
The minimum size is derived from the minimum size of the child unless it has been explicitely set. For a collapsed window, only the preferred width of the child component is taken into account.

Overrides:
getMinimumSize in class javax.swing.JComponent

getMaximumSize

public java.awt.Dimension getMaximumSize()
The maximum size is derived from the maximum size of the child unless it has been explicitely set. For a collapsed window, only the preferred width of the child component is taken into account.

Overrides:
getMaximumSize in class javax.swing.JComponent

doLayout

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

addSubwindowListener

public void addSubwindowListener(SubwindowListener listener)
Register a listener which will be notified of all changes in the collapsed state of the subwindow.


removeSubwindowListener

public void removeSubwindowListener(SubwindowListener listener)
Undo the registration of the given listener as a subwindow listener.