<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<!--NewPage-->
<html>
<head>
<!-- Generated by javadoc on Wed Jul 28 01:21:15 GMT 1999 -->
<title>
  Class java.awt.GridLayout
</title>
</head>
<body>
<a name="_top_"></a>
<pre>
<a href="packages.html">All Packages</a>  <a href="tree.html">Class Hierarchy</a>  <a href="Package-java.awt.html">This Package</a>  <a href="java.awt.GridBagLayout.html#_top_">Previous</a>  <a href="java.awt.Image.html#_top_">Next</a>  <a href="AllNames.html">Index</a></pre>
<hr>
<h1>
  Class java.awt.GridLayout
</h1>
<pre>
<a href="java.lang.Object.html#_top_">java.lang.Object</a>
   |
   +----java.awt.GridLayout
</pre>
<hr>
<dl>
  <dt> public class <b>GridLayout</b>
  <dt> extends <a href="java.lang.Object.html#_top_">Object</a>
  <dt> implements <a href="java.awt.LayoutManager.html#_top_">LayoutManager</a>, <a href="java.io.Serializable.html#_top_">Serializable</a>
</dl>
The <code>GridLayout</code> class is a layout manager that 
 lays out a container's components in a rectangular grid. 
 <p>
 The container is divided into equal-sized rectangles, 
 and one component is placed in each rectangle. 
 <p>
 For example, the following is an applet that lays out six buttons 
 into three rows and two columns: 
 <p>
 <hr><blockquote><pre>
 import java.awt.*;
 import java.applet.Applet;
 public class ButtonGrid extends Applet {
     public void init() {
         setLayout(new GridLayout(3,2));
         add(new Button("1"));
         add(new Button("2"));
         add(new Button("3"));
         add(new Button("4"));
         add(new Button("5"));
         add(new Button("6"));
     }
 }
 </pre></blockquote><hr>     
 <p>
 It produces the following output:
 <p>
 <img src="images-awt/GridLayout-1.gif" 
 ALIGN=center HSPACE=10 VSPACE=7>
 <p>
 When both the number of rows and the number of columns have 
 been set to non-zero values, either by a constructor or 
 by the <tt>setRows</tt> and <tt>setColumns</tt> methods, the number of 
 columns specified is ignored.  Instead, the number of 
 columns is determined from the specified number or rows 
 and the total number of components in the layout. So, for 
 example, if three rows and two columns have been specified 
 and nine components are added to the layout, then they will 
 be displayed as three rows of three columns.  Specifying 
 the number of columns affects the layout only when the 
 number of rows is set to zero.
<p>
<hr>
<a name="index"></a>
<h2>
  <img src="images/constructor-index.gif" width=275 height=38 alt="Constructor Index">
</h2>
<dl>
  <dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#GridLayout()"><b>GridLayout</b></a>()
  <dd>  Creates a grid layout with a default of one column per component,
 in a single row.
  <dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#GridLayout(int, int)"><b>GridLayout</b></a>(int, int)
  <dd>  Creates a grid layout with the specified number of rows and 
 columns.
  <dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#GridLayout(int, int, int, int)"><b>GridLayout</b></a>(int, int, int, int)
  <dd>  Creates a grid layout with the specified number of rows and 
 columns.
</dl>
<h2>
  <img src="images/method-index.gif" width=207 height=38 alt="Method Index">
</h2>
<dl>
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#addLayoutComponent(java.lang.String, java.awt.Component)"><b>addLayoutComponent</b></a>(String, Component)
  <dd>  Adds the specified component with the specified name to the layout.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getColumns()"><b>getColumns</b></a>()
  <dd>  Gets the number of columns in this layout.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getHgap()"><b>getHgap</b></a>()
  <dd>  Gets the horizontal gap between components.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getRows()"><b>getRows</b></a>()
  <dd>  Gets the number of rows in this layout.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getVgap()"><b>getVgap</b></a>()
  <dd>  Gets the vertical gap between components.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#layoutContainer(java.awt.Container)"><b>layoutContainer</b></a>(Container)
  <dd> 
 Lays out the specified container using this layout.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#minimumLayoutSize(java.awt.Container)"><b>minimumLayoutSize</b></a>(Container)
  <dd>  Determines the minimum size of the container argument using this 
 grid layout.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#preferredLayoutSize(java.awt.Container)"><b>preferredLayoutSize</b></a>(Container)
  <dd> 
 Determines the preferred size of the container argument using 
 this grid layout.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#removeLayoutComponent(java.awt.Component)"><b>removeLayoutComponent</b></a>(Component)
  <dd>  Removes the specified component from the layout.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#setColumns(int)"><b>setColumns</b></a>(int)
  <dd>  Sets the number of columns in this layout to the specified value.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#setHgap(int)"><b>setHgap</b></a>(int)
  <dd>  Sets the horizontal gap between components to the specified value.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#setRows(int)"><b>setRows</b></a>(int)
  <dd>  Sets the number of rows in this layout to the specified value.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#setVgap(int)"><b>setVgap</b></a>(int)
  <dd>  Sets the vertical gap between components to the specified value.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#toString()"><b>toString</b></a>()
  <dd>  Returns the string representation of this grid layout's values.
</dl>
<a name="constructors"></a>
<h2>
  <img src="images/constructors.gif" width=231 height=38 alt="Constructors">
</h2>
<a name="GridLayout"></a>
<a name="GridLayout()"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a>
<b>GridLayout</b>
<pre>
 public GridLayout()
</pre>
<dl>
  <dd> Creates a grid layout with a default of one column per component,
 in a single row.
<p>
</dl>
<a name="GridLayout(int, int)"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a>
<b>GridLayout</b>
<pre>
 public GridLayout(int rows,
                   int cols)
</pre>
<dl>
  <dd> Creates a grid layout with the specified number of rows and 
 columns. All components in the layout are given equal size. 
 <p>
 One, but not both, of <code>rows</code> and <code>cols</code> can 
 be zero, which means that any number of objects can be placed in a 
 row or in a column.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> rows - the rows, with the value zero meaning
                   any number of rows.
    <dd> cols - the columns, with the value zero meaning
                   any number of columns.
  </dl></dd>
</dl>
<a name="GridLayout(int, int, int, int)"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a>
<b>GridLayout</b>
<pre>
 public GridLayout(int rows,
                   int cols,
                   int hgap,
                   int vgap)
</pre>
<dl>
  <dd> Creates a grid layout with the specified number of rows and 
 columns. All components in the layout are given equal size. 
 <p>
 In addition, the horizontal and vertical gaps are set to the 
 specified values. Horizontal gaps are placed at the left and 
 right edges, and between each of the columns. Vertical gaps are 
 placed at the top and bottom edges, and between each of the rows. 
 <p>
 One, but not both, of <code>rows</code> and <code>cols</code> can 
 be zero, which means that any number of objects can be placed in a 
 row or in a column.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> rows - the rows, with the value zero meaning
                   any number of rows.
    <dd> cols - the columns, with the value zero meaning
                   any number of columns.
    <dd> hgap - the horizontal gap.
    <dd> vgap - the vertical gap.
    <dt> <b>Throws:</b> <a href="java.lang.IllegalArgumentException.html#_top_">IllegalArgumentException</a>
    <dd> if the of <code>rows</code>
                   or <code>cols</code> is invalid.
  </dl></dd>
</dl>
<a name="methods"></a>
<h2>
  <img src="images/methods.gif" width=151 height=38 alt="Methods">
</h2>
<a name="getRows()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getRows"><b>getRows</b></a>
<pre>
 public int getRows()
</pre>
<dl>
  <dd> Gets the number of rows in this layout.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> the number of rows in this layout.
  </dl></dd>
</dl>
<a name="setRows(int)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="setRows"><b>setRows</b></a>
<pre>
 public void setRows(int rows)
</pre>
<dl>
  <dd> Sets the number of rows in this layout to the specified value.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> rows - the number of rows in this layout.
    <dt> <b>Throws:</b> <a href="java.lang.IllegalArgumentException.html#_top_">IllegalArgumentException</a>
    <dd> if the value of both
               <code>rows</code> and <code>cols</code> is set to zero.
  </dl></dd>
</dl>
<a name="getColumns()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getColumns"><b>getColumns</b></a>
<pre>
 public int getColumns()
</pre>
<dl>
  <dd> Gets the number of columns in this layout.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> the number of columns in this layout.
  </dl></dd>
</dl>
<a name="setColumns(int)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="setColumns"><b>setColumns</b></a>
<pre>
 public void setColumns(int cols)
</pre>
<dl>
  <dd> Sets the number of columns in this layout to the specified value. 
 Setting the number of columns has no affect on the layout 
 if the number of rows specified by a constructor or by 
 the <tt>setRows</tt> method is non-zero. In that case, the number 
 of columns displayed in the layout is determined by the total 
 number of components and the number of rows specified.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> cols - the number of columns in this layout.
    <dt> <b>Throws:</b> <a href="java.lang.IllegalArgumentException.html#_top_">IllegalArgumentException</a>
    <dd> if the value of both
               <code>rows</code> and <code>cols</code> is set to zero.
  </dl></dd>
</dl>
<a name="getHgap()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getHgap"><b>getHgap</b></a>
<pre>
 public int getHgap()
</pre>
<dl>
  <dd> Gets the horizontal gap between components.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> the horizontal gap between components.
  </dl></dd>
</dl>
<a name="setHgap(int)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="setHgap"><b>setHgap</b></a>
<pre>
 public void setHgap(int hgap)
</pre>
<dl>
  <dd> Sets the horizontal gap between components to the specified value.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> hgap - the horizontal gap between components.
  </dl></dd>
</dl>
<a name="getVgap()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getVgap"><b>getVgap</b></a>
<pre>
 public int getVgap()
</pre>
<dl>
  <dd> Gets the vertical gap between components.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> the vertical gap between components.
  </dl></dd>
</dl>
<a name="setVgap(int)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="setVgap"><b>setVgap</b></a>
<pre>
 public void setVgap(int vgap)
</pre>
<dl>
  <dd> Sets the vertical gap between components to the specified value.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> vgap - the vertical gap between components.
  </dl></dd>
</dl>
<a name="addLayoutComponent(java.lang.String, java.awt.Component)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="addLayoutComponent"><b>addLayoutComponent</b></a>
<pre>
 public void addLayoutComponent(<a href="java.lang.String.html#_top_">String</a> name,
                                <a href="java.awt.Component.html#_top_">Component</a> comp)
</pre>
<dl>
  <dd> Adds the specified component with the specified name to the layout.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> name - the name of the component.
    <dd> comp - the component to be added.
  </dl></dd>
</dl>
<a name="removeLayoutComponent(java.awt.Component)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="removeLayoutComponent"><b>removeLayoutComponent</b></a>
<pre>
 public void removeLayoutComponent(<a href="java.awt.Component.html#_top_">Component</a> comp)
</pre>
<dl>
  <dd> Removes the specified component from the layout.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> comp - the component to be removed.
  </dl></dd>
</dl>
<a name="preferredLayoutSize(java.awt.Container)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="preferredLayoutSize"><b>preferredLayoutSize</b></a>
<pre>
 public <a href="java.awt.Dimension.html#_top_">Dimension</a> preferredLayoutSize(<a href="java.awt.Container.html#_top_">Container</a> parent)
</pre>
<dl>
  <dd> Determines the preferred size of the container argument using 
 this grid layout. 
 <p>
 The preferred width of a grid layout is the largest preferred 
 width of any of the widths in the container times the number of 
 columns, plus the horizontal padding times the number of columns 
 plus one, plus the left and right insets of the target container. 
 <p>
 The preferred height of a grid layout is the largest preferred 
 height of any of the widths in the container times the number of 
 rows, plus the vertical padding times the number of rows plus one, 
 plus the top and left insets of the target container.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> target - the container in which to do the layout.
    <dt> <b>Returns:</b>
    <dd> the preferred dimensions to lay out the
                      subcomponents of the specified container.
    <dt> <b>See Also:</b>
    <dd> <a href="#minimumLayoutSize">minimumLayoutSize</a>, <a href="java.awt.Container.html#getPreferredSize()">getPreferredSize</a>
  </dl></dd>
</dl>
<a name="minimumLayoutSize(java.awt.Container)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="minimumLayoutSize"><b>minimumLayoutSize</b></a>
<pre>
 public <a href="java.awt.Dimension.html#_top_">Dimension</a> minimumLayoutSize(<a href="java.awt.Container.html#_top_">Container</a> parent)
</pre>
<dl>
  <dd> Determines the minimum size of the container argument using this 
 grid layout. 
 <p>
 The minimum width of a grid layout is the largest minimum width 
 of any of the widths in the container times the number of columns, 
 plus the horizontal padding times the number of columns plus one, 
 plus the left and right insets of the target container. 
 <p>
 The minimum height of a grid layout is the largest minimum height 
 of any of the widths in the container times the number of rows, 
 plus the vertical padding times the number of rows plus one, plus 
 the top and left insets of the target container.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> target - the container in which to do the layout.
    <dt> <b>Returns:</b>
    <dd> the minimum dimensions needed to lay out the
                      subcomponents of the specified container.
    <dt> <b>See Also:</b>
    <dd> <a href="#preferredLayoutSize">preferredLayoutSize</a>, <a href="java.awt.Container.html#doLayout">doLayout</a>
  </dl></dd>
</dl>
<a name="layoutContainer(java.awt.Container)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="layoutContainer"><b>layoutContainer</b></a>
<pre>
 public void layoutContainer(<a href="java.awt.Container.html#_top_">Container</a> parent)
</pre>
<dl>
  <dd> Lays out the specified container using this layout. 
 <p>
 This method reshapes the components in the specified target 
 container in order to satisfy the constraints of the 
 <code>GridLayout</code> object. 
 <p>
 The grid layout manager determines the size of individual 
 components by dividing the free space in the container into 
 equal-sized portions according to the number of rows and columns 
 in the layout. The container's free space equals the container's 
 size minus any insets and any specified horizontal or vertical 
 gap. All components in a grid layout are given the same size.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> target - the container in which to do the layout.
    <dt> <b>See Also:</b>
    <dd> <a href="java.awt.Container.html#_top_">Container</a>, <a href="java.awt.Container.html#doLayout">doLayout</a>
  </dl></dd>
</dl>
<a name="toString()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="toString"><b>toString</b></a>
<pre>
 public <a href="java.lang.String.html#_top_">String</a> toString()
</pre>
<dl>
  <dd> Returns the string representation of this grid layout's values.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> a string representation of this grid layout.
    <dt> <b>Overrides:</b>
    <dd> <a href="java.lang.Object.html#toString()">toString</a> in class <a href="java.lang.Object.html#_top_">Object</a>
  </dl></dd>
</dl>
<hr>
<pre>
<a href="packages.html">All Packages</a>  <a href="tree.html">Class Hierarchy</a>  <a href="Package-java.awt.html">This Package</a>  <a href="java.awt.GridBagLayout.html#_top_">Previous</a>  <a href="java.awt.Image.html#_top_">Next</a>  <a href="AllNames.html">Index</a></pre>
</body>
</html>
