buoy.widget
Class ExplicitContainer

java.lang.Object
  extended by buoy.event.EventSource
      extended by buoy.widget.Widget
          extended by buoy.widget.WidgetContainer
              extended by buoy.widget.ExplicitContainer

public class ExplicitContainer
extends WidgetContainer

ExplicitContainer is a WidgetContainer which allows the sizes and positions of its children to be set explicitly.

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

Author:
Peter Eastman

Constructor Summary
ExplicitContainer()
          Create a new ExplicitContainer.
 
Method Summary
 void add(Widget widget, java.awt.Rectangle bounds)
          Add a Widget to this container.
 Widget getChild(int i)
          Get the i'th child of this container.
 java.awt.Rectangle getChildBounds(int index)
          Get the position of a child Widget within this container.
 java.awt.Rectangle getChildBounds(Widget widget)
          Get the position of a child Widget within this container.
 int getChildCount()
          Get the number of children in this container.
 int getChildIndex(Widget widget)
          Get the index of a particular Widget.
 java.util.Collection<Widget> getChildren()
          Get a Collection containing all child Widgets of this container.
 javax.swing.JPanel getComponent()
          Get the java.awt.Component corresponding to this Widget.
 java.awt.Dimension getMinimumSize()
          Get the smallest size at which this Widget can reasonably be drawn.
 java.awt.Dimension getPreferredSize()
          Get the preferred size at which this Widget will look best.
 void layoutChildren()
          Layout the child Widgets.
 void remove(Widget widget)
          Remove a child Widget from this container.
 void removeAll()
          Remove all child Widgets from this container.
 void setChildBounds(int index, java.awt.Rectangle bounds)
          Set the position of a child Widget within this container.
 void setChildBounds(Widget widget, java.awt.Rectangle bounds)
          Set the position of a child Widget within this container.
 
Methods inherited from class buoy.widget.WidgetContainer
isOpaque, setOpaque
 
Methods inherited from class buoy.widget.Widget
addEventLink, dispatchEvent, getBackground, getBounds, getCursor, getFont, getMaximumSize, getName, getParent, hasFocus, isEnabled, isFocusable, isVisible, repaint, requestFocus, setBackground, setCursor, setEnabled, setFocusable, setFont, setName, setVisible
 
Methods inherited from class buoy.event.EventSource
addEventLink, addEventLink, removeEventLink
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExplicitContainer

public ExplicitContainer()
Create a new ExplicitContainer.

Method Detail

getComponent

public javax.swing.JPanel getComponent()
Description copied from class: Widget
Get the java.awt.Component corresponding to this Widget.

Overrides:
getComponent in class Widget

getChildCount

public int getChildCount()
Get the number of children in this container.

Specified by:
getChildCount in class WidgetContainer

getChild

public Widget getChild(int i)
Get the i'th child of this container.


getChildren

public java.util.Collection<Widget> getChildren()
Get a Collection containing all child Widgets of this container.

Specified by:
getChildren in class WidgetContainer

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.

Specified by:
layoutChildren in class WidgetContainer

add

public void add(Widget widget,
                java.awt.Rectangle bounds)
Add a Widget to this container.

Parameters:
widget - the Widget to add
bounds - the location and size at which the Widget should appear

getChildIndex

public int getChildIndex(Widget widget)
Get the index of a particular Widget.

Parameters:
widget - the Widget to locate
Returns:
the index of the Widget within this container

getChildBounds

public java.awt.Rectangle getChildBounds(int index)
Get the position of a child Widget within this container.

Parameters:
index - the index of the Widget for which to get the location
Returns:
the bounding rectangle to be used for the Widget

setChildBounds

public void setChildBounds(int index,
                           java.awt.Rectangle bounds)
Set the position of a child Widget within this container.

Parameters:
index - the index of the Widget to move
bounds - the location and size at which the Widget should appear

getChildBounds

public java.awt.Rectangle getChildBounds(Widget widget)
Get the position of a child Widget within this container.

Parameters:
widget - the Widget for which to get the location
Returns:
the bounding rectangle to be used for the Widget, or null if it is not a child of this container

setChildBounds

public void setChildBounds(Widget widget,
                           java.awt.Rectangle bounds)
Set the position of a child Widget within this container.

Parameters:
widget - the Widget to move
bounds - the location and size at which the Widget should appear

remove

public void remove(Widget widget)
Remove a child Widget from this container.

Specified by:
remove in class WidgetContainer
Parameters:
widget - the Widget to remove

removeAll

public void removeAll()
Remove all child Widgets from this container.

Specified by:
removeAll in class WidgetContainer

getMinimumSize

public java.awt.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 class Widget

getPreferredSize

public java.awt.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 class Widget


Written by Peter Eastman.