buoy.widget

Class BorderContainer


public class BorderContainer
extends WidgetContainer

BorderContainer is a WidgetContainer which may have up to five children: one along each edge, and a fifth one in the center. When this container is resized, the center component grows to take up as much space as possible.

In addition to the event types generated by all Widgets, BorderContainers generate the following event types:

Author:
Peter Eastman

Nested Class Summary

static class
BorderContainer.Position
This inner class represents a position within the container.

Field Summary

static BorderContainer.Position
CENTER
static BorderContainer.Position
EAST
static BorderContainer.Position
NORTH
static BorderContainer.Position
SOUTH
static BorderContainer.Position
WEST

Constructor Summary

BorderContainer()
Create a new BorderContainer.

Method Summary

void
add(Widget widget, BorderContainer.Position where)
Add a Widget to this container, using the default LayoutInfo to position it.
void
add(Widget widget, BorderContainer.Position where, LayoutInfo layout)
Add a Widget to this container.
Widget
getChild(BorderContainer.Position where)
Get the child in a particular location.
int
getChildCount()
Get the number of children in this container.
LayoutInfo
getChildLayout(BorderContainer.Position where)
Get the LayoutInfo for the Widget in a particular location.
LayoutInfo
getChildLayout(Widget widget)
Get the LayoutInfo for a particular Widget.
BorderContainer.Position
getChildPosition(Widget widget)
Get the Position of a particular Widget.
Collection
getChildren()
Get a Collection containing all child Widgets of this container.
boolean
getCornersAreVertical()
Get whether the vertical Widgets (EAST and WEST) or the horizontal Widgets (NORTH and SOUTH) extend all the way to the corners.
LayoutInfo
getDefaultLayout()
Get the default LayoutInfo.
Dimension
getMinimumSize()
Get the smallest size at which this Widget can reasonably be drawn.
Dimension
getPreferredSize()
Get the preferred size at which this Widget will look best.
void
layoutChildren()
Layout the child Widgets.
void
remove(BorderContainer.Position where)
Remove a child Widget from this container.
void
remove(Widget widget)
Remove a child Widget from this container.
void
removeAll()
Remove all child Widgets from this container.
void
setChildLayout(BorderContainer.Position where, LayoutInfo layout)
Set the LayoutInfo for the Widget in a particular location.
void
setChildLayout(Widget widget, LayoutInfo layout)
Set the LayoutInfo for a particular Widget.
void
setCornersAreVertical(boolean vertical)
Set whether the vertical Widgets (EAST and WEST) or the horizontal Widgets (NORTH and SOUTH) extend all the way to the corners.
void
setDefaultLayout(LayoutInfo layout)
Set the default LayoutInfo.

Methods inherited from class buoy.widget.WidgetContainer

getChildCount, getChildren, isOpaque, layoutChildren, remove, removeAll, setOpaque

Methods inherited from class buoy.widget.Widget

addEventLink, dispatchEvent, getBackground, getBounds, getComponent, getCursor, getFont, getMaximumSize, getMinimumSize, getName, getParent, getPreferredSize, hasFocus, isEnabled, isFocusable, isVisible, repaint, requestFocus, setBackground, setCursor, setEnabled, setFocusable, setFont, setName, setVisible

Methods inherited from class buoy.event.EventSource

addEventLink, addEventLink, addEventLink, dispatchEvent, removeEventLink

Field Details

CENTER

public static final BorderContainer.Position CENTER

EAST

public static final BorderContainer.Position EAST

NORTH

public static final BorderContainer.Position NORTH

SOUTH

public static final BorderContainer.Position SOUTH

WEST

public static final BorderContainer.Position WEST

Constructor Details

BorderContainer

public BorderContainer()
Create a new BorderContainer.

Method Details

add

public void add(Widget widget,
                BorderContainer.Position where)
Add a Widget to this container, using the default LayoutInfo to position it.
Parameters:
widget - the Widget to add
where - the location to add it (CENTER, NORTH, EAST, SOUTH, or WEST)

add

public void add(Widget widget,
                BorderContainer.Position where,
                LayoutInfo layout)
Add a Widget to this container.
Parameters:
widget - the Widget to add
where - the location to add it (CENTER, NORTH, EAST, SOUTH, or WEST)
layout - the LayoutInfo to use for this Widget. If null, the default LayoutInfo will be used.

getChild

public Widget getChild(BorderContainer.Position where)
Get the child in a particular location.
Parameters:
where - the location of the Widget to get (CENTER, NORTH, EAST, SOUTH, or WEST)

getChildCount

public int getChildCount()
Get the number of children in this container.
Overrides:
getChildCount in interface WidgetContainer

getChildLayout

public LayoutInfo getChildLayout(BorderContainer.Position where)
Get the LayoutInfo for the Widget in a particular location.
Parameters:
where - the location of the Widget (CENTER, NORTH, EAST, SOUTH, or WEST)
Returns:
the LayoutInfo being used for that Widget. This may return null, which indicates that the default LayoutInfo is being used.

getChildLayout

public LayoutInfo getChildLayout(Widget widget)
Get the LayoutInfo for a particular Widget.
Parameters:
widget - the Widget for which to get the LayoutInfo
Returns:
the LayoutInfo being used for that Widget. This may return null, which indicates that the default LayoutInfo is being used. It will also return null if the specified Widget is not a child of this container.

getChildPosition

public BorderContainer.Position getChildPosition(Widget widget)
Get the Position of a particular Widget.
Parameters:
widget - the Widget for which to get the Position
Returns:
the Position at which that Widget is located, or null if the specified Widget is not a child of this container.

getChildren

public Collection getChildren()
Get a Collection containing all child Widgets of this container.
Overrides:
getChildren in interface WidgetContainer

getCornersAreVertical

public boolean getCornersAreVertical()
Get whether the vertical Widgets (EAST and WEST) or the horizontal Widgets (NORTH and SOUTH) extend all the way to the corners.

getDefaultLayout

public LayoutInfo getDefaultLayout()
Get the default LayoutInfo.

getMinimumSize

public Dimension getMinimumSize()
Get the smallest size at which this Widget can reasonably be drawn. When a WidgetContainer lays out its contents, it will attempt never to make this Widget smaller than its minimum size.
Overrides:
getMinimumSize in interface Widget

getPreferredSize

public Dimension getPreferredSize()
Get the preferred size at which this Widget will look best. When a WidgetContainer lays out its contents, it will attempt to make this Widget as close as possible to its preferred size.
Overrides:
getPreferredSize in interface Widget

layoutChildren

public void layoutChildren()
Layout the child Widgets. This may be invoked whenever something has changed (the size of this WidgetContainer, the preferred size of one of its children, etc.) that causes the layout to no longer be correct. If a child is itself a WidgetContainer, its layoutChildren() method will be called in turn.
Overrides:
layoutChildren in interface WidgetContainer

remove

public void remove(BorderContainer.Position where)
Remove a child Widget from this container.
Parameters:
where - the location of the Widget to remove (CENTER, NORTH, EAST, SOUTH, or WEST)

remove

public void remove(Widget widget)
Remove a child Widget from this container.
Overrides:
remove in interface WidgetContainer
Parameters:
widget - the Widget to remove

removeAll

public void removeAll()
Remove all child Widgets from this container.
Overrides:
removeAll in interface WidgetContainer

setChildLayout

public void setChildLayout(BorderContainer.Position where,
                           LayoutInfo layout)
Set the LayoutInfo for the Widget in a particular location.
Parameters:
where - the location of the Widget (CENTER, NORTH, EAST, SOUTH, or WEST)
layout - the new LayoutInfo. If null, the default LayoutInfo will be used.

setChildLayout

public void setChildLayout(Widget widget,
                           LayoutInfo layout)
Set the LayoutInfo for a particular Widget.
Parameters:
widget - the Widget for which to set the LayoutInfo
layout - the new LayoutInfo. If null, the default LayoutInfo will be used.

setCornersAreVertical

public void setCornersAreVertical(boolean vertical)
Set whether the vertical Widgets (EAST and WEST) or the horizontal Widgets (NORTH and SOUTH) extend all the way to the corners.

setDefaultLayout

public void setDefaultLayout(LayoutInfo layout)
Set the default LayoutInfo.

Written by Peter Eastman.