dog.gui
Class BoxLayout

java.lang.Object
  |
  +--dog.gui.BoxLayout
All Implemented Interfaces:
java.awt.LayoutManager

public class BoxLayout
extends java.lang.Object
implements java.awt.LayoutManager

A box layout is used to lay out components in a container. It will arranges the components either horizontally or vertically. In a horizontal box layout, each component is expanded to the height of the container and the components are laid out from left to right. In a vertical box layout, each component is expanded to the width of the container and the components are laid out from top to bottom.


Field Summary
static int HORIZONTAL
          The horizontal orientation.
protected  int orientation
          The orientation of the layout.
static int VERTICAL
          The vertical orientation.
 
Constructor Summary
BoxLayout()
          Constructs a new vertical box layout with the default 5-unit horizontal and vertical gap.
BoxLayout(int orientation)
          Constructs a new box layout with the specified orientation and the default 5-unit horizontal and vertical gap.
BoxLayout(int orientation, int hgap, int vgap)
          Constructs a new layout with the specified orientation and gap values.
 
Method Summary
 void addLayoutComponent(java.lang.String name, java.awt.Component comp)
          Adds the specified component to the layout.
 int getHgap()
          Returns the horizontal gap between components.
 int getOrientation()
          Returns the orientation of this layout (HORIZONTAL or VERTICAL).
 int getVgap()
          Returns the vertical gap between components.
 void layoutContainer(java.awt.Container target)
          Lays out the container.
 java.awt.Dimension minimumLayoutSize(java.awt.Container target)
          Returns the minimum dimensions needed to layout the components contained in the specified target container.
 java.awt.Dimension preferredLayoutSize(java.awt.Container target)
          Returns the preferred dimensions for this layout given the components in the specified target container.
 void removeLayoutComponent(java.awt.Component comp)
          Removes the specified component from the layout.
 void setHgap(int hgap)
          Sets the horizontal gap between components.
 void setOrientation(int orientation)
          Sets the orientation value for this layout.
 void setVgap(int vgap)
          Sets the vertical gap between components.
 java.lang.String toString()
          Returns the string representation of this layout's values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

HORIZONTAL

public static final int HORIZONTAL
The horizontal orientation.

VERTICAL

public static final int VERTICAL
The vertical orientation.

orientation

protected int orientation
The orientation of the layout.
Constructor Detail

BoxLayout

public BoxLayout()
Constructs a new vertical box layout with the default 5-unit horizontal and vertical gap.

BoxLayout

public BoxLayout(int orientation)
Constructs a new box layout with the specified orientation and the default 5-unit horizontal and vertical gap.
Parameters:
orientation - the orientation of the layout

BoxLayout

public BoxLayout(int orientation,
                 int hgap,
                 int vgap)
Constructs a new layout with the specified orientation and gap values.
Parameters:
orientation - the orientation of the layout
hgap - the horizontal gap variable
vgap - the vertical gap variable
Method Detail

getOrientation

public int getOrientation()
Returns the orientation of this layout (HORIZONTAL or VERTICAL).

setOrientation

public void setOrientation(int orientation)
Sets the orientation value for this layout.
Parameters:
orientation - the orientation value (HORIZONTAL or VERTICAL).

getHgap

public int getHgap()
Returns the horizontal gap between components.

setHgap

public void setHgap(int hgap)
Sets the horizontal gap between components.
Parameters:
hgap - the horizontal gap between components

getVgap

public int getVgap()
Returns the vertical gap between components.

setVgap

public void setVgap(int vgap)
Sets the vertical gap between components.
Parameters:
vgap - the vertical gap between components

addLayoutComponent

public void addLayoutComponent(java.lang.String name,
                               java.awt.Component comp)
Adds the specified component to the layout. Not used by this class.
Specified by:
addLayoutComponent in interface java.awt.LayoutManager
Parameters:
name - the name of the component
comp - the the component to be added

removeLayoutComponent

public void removeLayoutComponent(java.awt.Component comp)
Removes the specified component from the layout. Not used by this class.
Specified by:
removeLayoutComponent in interface java.awt.LayoutManager
Parameters:
comp - the component to remove

preferredLayoutSize

public java.awt.Dimension preferredLayoutSize(java.awt.Container target)
Returns the preferred dimensions for this layout given the components in the specified target container.
Specified by:
preferredLayoutSize in interface java.awt.LayoutManager
Parameters:
target - the component which needs to be laid out
See Also:
Container, minimumLayoutSize(java.awt.Container)

minimumLayoutSize

public java.awt.Dimension minimumLayoutSize(java.awt.Container target)
Returns the minimum dimensions needed to layout the components contained in the specified target container.
Specified by:
minimumLayoutSize in interface java.awt.LayoutManager
Parameters:
target - the component which needs to be laid out
See Also:
preferredLayoutSize(java.awt.Container)

layoutContainer

public void layoutContainer(java.awt.Container target)
Lays out the container.
Specified by:
layoutContainer in interface java.awt.LayoutManager
Parameters:
target - the specified component being laid out.
See Also:
Container

toString

public java.lang.String toString()
Returns the string representation of this layout's values.
Overrides:
toString in class java.lang.Object