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);
addSubwindowListener
public void addSubwindowListener(SubwindowListener listener)
Register a listener which will be notified of all changes in the collapsed
state of the subwindow.
doLayout
public void doLayout()
getChildComponent
public 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.
getHorizontalWindowPadding
public int getHorizontalWindowPadding()
Horizontal padding for this subwindow.
getMaximumSize
public 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.
getMinimumSize
public 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.
getPreferredSize
public 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.
getTitleBarBorderColor
public Color getTitleBarBorderColor()
The color of the subwindow border, as set by the user.
- null when the user did not explicitely set this color
getTitleBarColor
public Color getTitleBarColor()
The color of the title bar.
getTitleBarColorNoFocus
public Color getTitleBarColorNoFocus()
The color of the title bar when the subwindow
does not own the focus, as set by the user.
- null when the user did not explicitely set this color
getTitleBarHeight
public int getTitleBarHeight()
The height of the title bar in pixels.
getTitleBarTextColor
public Color getTitleBarTextColor()
Return the color for the text of the title bar.
getTitleBarTextColorNoFocus
public Color getTitleBarTextColorNoFocus()
The color of the text in the title bar when the subwindow
does not own the focus, as set by the user.
- null when the user did not explicitely set this color
getVerticalWindowPadding
public int getVerticalWindowPadding()
Vertical padding for this subwindow.
isCollapsed
public boolean isCollapsed()
Is this window collapsed?
paintComponent
public void paintComponent(Graphics g)
removeSubwindowListener
public void removeSubwindowListener(SubwindowListener listener)
Undo the registration of the given listener as a subwindow listener.
setCollapsed
public void setCollapsed(boolean collapsed)
Change the 'collapsed' state of this window.
setHorizontalWindowPadding
public void setHorizontalWindowPadding(int horizontalWindowPadding)
Sets the horizontal for this subwindow.
setTitleBarBorderColor
public void setTitleBarBorderColor(Color titleBarBorderColor)
Set the color to be used for the subwindow border.
Defaults to the title bar color.
setTitleBarColor
public void setTitleBarColor(Color titleBarColor)
Set the color to be used for the title bar. Defaults to gray.
setTitleBarColorNoFocus
public void setTitleBarColorNoFocus(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.
setTitleBarHeight
public void setTitleBarHeight(int titleBarHeight)
Set the height of the title bar.
setTitleBarTextColor
public void setTitleBarTextColor(Color titleBarTextColor)
Set the color to be used for the text in the title bar. Defaults to white
setTitleBarTextColorNoFocus
public void setTitleBarTextColorNoFocus(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.
setVerticalWindowPadding
public void setVerticalWindowPadding(int verticalWindowPadding)
Sets the vertical for this subwindow.
toggleCollapsed
public void toggleCollapsed()
Toggle the 'collapsed' state of this window.