java.awt
Class GridLayout

java.lang.Object
  |
  +--java.awt.GridLayout
All Implemented Interfaces:
LayoutManager

public class GridLayout
extends Object
implements LayoutManager

A layout manager for a container that lays out grids.


Constructor Summary
GridLayout(int rows, int cols)
          Creates a grid layout with the specified rows and columns.
GridLayout(int rows, int cols, int hgap, int vgap)
          Creates a grid layout with the specified rows, columns, horizontal gap, and vertical gap.
 
Method Summary
 void addLayoutComponent(String name, Component comp)
          Adds the specified component with the specified name to the layout.
 void layoutContainer(Container parent)
          Lays out the container in the specified panel.
 Dimension minimumLayoutSize(Container parent)
          Returns the minimum dimensions needed to layout the components contained in the specified panel.
 Dimension preferredLayoutSize(Container parent)
          Returns the preferred dimensions for this layout given the components int the specified panel.
 void removeLayoutComponent(Component comp)
          Removes the specified component from the layout.
 String toString()
          Returns the String representation of this GridLayout's values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GridLayout

public GridLayout(int rows,
                  int cols)
Creates a grid layout with the specified rows and columns.

Parameters:
rows - the rows
cols - the columns

GridLayout

public GridLayout(int rows,
                  int cols,
                  int hgap,
                  int vgap)
Creates a grid layout with the specified rows, columns, horizontal gap, and vertical gap.

Parameters:
rows - the rows; zero means 'any number.'
cols - the columns; zero means 'any number.' Only one of 'rows' and 'cols' can be zero, not both.
hgap - the horizontal gap variable
vgap - the vertical gap variable
Throws:
IllegalArgumentException - If the rows and columns are invalid.
Method Detail

addLayoutComponent

public void addLayoutComponent(String name,
                               Component comp)
Adds the specified component with the specified name to the layout.

Specified by:
addLayoutComponent in interface LayoutManager
Parameters:
name - the name of the component
comp - the component to be added

removeLayoutComponent

public void removeLayoutComponent(Component comp)
Removes the specified component from the layout. Does not apply.

Specified by:
removeLayoutComponent in interface LayoutManager
Parameters:
comp - the component to be removed

preferredLayoutSize

public Dimension preferredLayoutSize(Container parent)
Returns the preferred dimensions for this layout given the components int the specified panel.

Specified by:
preferredLayoutSize in interface LayoutManager
Parameters:
parent - the component which needs to be laid out
See Also:
minimumLayoutSize(java.awt.Container)

minimumLayoutSize

public Dimension minimumLayoutSize(Container parent)
Returns the minimum dimensions needed to layout the components contained in the specified panel.

Specified by:
minimumLayoutSize in interface LayoutManager
Parameters:
parent - the component which needs to be laid out
See Also:
preferredLayoutSize(java.awt.Container)

layoutContainer

public void layoutContainer(Container parent)
Lays out the container in the specified panel.

Specified by:
layoutContainer in interface LayoutManager
Parameters:
parent - the specified component being laid out
See Also:
Container

toString

public String toString()
Returns the String representation of this GridLayout's values.

Overrides:
toString in class Object