Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

java.awt
Class GridLayout  view GridLayout download GridLayout.java

java.lang.Object
  extended byjava.awt.GridLayout
All Implemented Interfaces:
LayoutManager, java.io.Serializable

public class GridLayout
extends java.lang.Object
implements LayoutManager, java.io.Serializable

This class implements a grid-based layout scheme. Components are all given the same size and are laid out from left to right and top to bottom. A GridLayout is configured with a number of rows and a number of columns. If both are specified, then the number of columns is ignored and is derived from the number of rows and the total number of components. If either is zero then that dimension is computed based on the actual size of the container. An exception is thrown if an attempt is made to set both the number of rows and the number of columns to 0. This class also supports horizontal and vertical gaps; these are used as spacing between cells.


Field Summary
private  int cols
           
private  int hgap
           
private  int rows
           
(package private) static long serialVersionUID
           
private  int vgap
           
 
Constructor Summary
GridLayout()
          Create a new GridLayout with one row and any number of columns.
GridLayout(int rows, int cols)
          Create a new GridLayout with the specified number of rows and columns.
GridLayout(int rows, int cols, int hgap, int vgap)
          Create a new GridLayout with the specified number of rows and columns and the specified gaps.
 
Method Summary
 void addLayoutComponent(java.lang.String name, Component comp)
          Add a new component to the layout.
 int getColumns()
          Return the number of columns in this layout.
 int getHgap()
          Return the horizontal gap.
 int getRows()
          Return the number of rows in this layout.
private  Dimension getSize(Container parent, boolean is_min)
           
 int getVgap()
          Return the vertical gap.
 void layoutContainer(Container parent)
          Lay out the container's components based on current settings.
 Dimension minimumLayoutSize(Container cont)
          Get the minimum layout size of the container.
 Dimension preferredLayoutSize(Container cont)
          Get the preferred layout size of the container.
 void removeLayoutComponent(Component comp)
          Remove the indicated component from this layout manager.
 void setColumns(int newCols)
          Set the number of columns.
 void setHgap(int hgap)
          Set the horizontal gap
 void setRows(int newRows)
          Set the number of rows
 void setVgap(int vgap)
          Set the vertical gap.
 java.lang.String toString()
          Return String description of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

static final long serialVersionUID
See Also:
Constant Field Values

cols

private int cols

rows

private int rows

hgap

private int hgap

vgap

private int vgap
Constructor Detail

GridLayout

public GridLayout()
Create a new GridLayout with one row and any number of columns. Both gaps are set to 0.


GridLayout

public GridLayout(int rows,
                  int cols)
Create a new GridLayout with the specified number of rows and columns. Both gaps are set to 0. Note that the row and column settings cannot both be zero. If both the row and column values are non-zero, the rows value takes precedence.


GridLayout

public GridLayout(int rows,
                  int cols,
                  int hgap,
                  int vgap)
Create a new GridLayout with the specified number of rows and columns and the specified gaps. Note that the row and column settings cannot both be zero. If both the row and column values are non-zero, the rows value takes precedence.

Method Detail

addLayoutComponent

public void addLayoutComponent(java.lang.String name,
                               Component comp)
Add a new component to the layout. This particular implementation does nothing.

Specified by:
addLayoutComponent in interface LayoutManager

getColumns

public int getColumns()
Return the number of columns in this layout.


getHgap

public int getHgap()
Return the horizontal gap.


getRows

public int getRows()
Return the number of rows in this layout.


getVgap

public int getVgap()
Return the vertical gap.


layoutContainer

public void layoutContainer(Container parent)
Lay out the container's components based on current settings. The free space in the container is divided evenly into the specified number of rows and columns in this object.

Specified by:
layoutContainer in interface LayoutManager

minimumLayoutSize

public Dimension minimumLayoutSize(Container cont)
Get the minimum layout size of the container.

Specified by:
minimumLayoutSize in interface LayoutManager

preferredLayoutSize

public Dimension preferredLayoutSize(Container cont)
Get the preferred layout size of the container.

Specified by:
preferredLayoutSize in interface LayoutManager

removeLayoutComponent

public void removeLayoutComponent(Component comp)
Remove the indicated component from this layout manager. This particular implementation does nothing.

Specified by:
removeLayoutComponent in interface LayoutManager

setColumns

public void setColumns(int newCols)
Set the number of columns.


setHgap

public void setHgap(int hgap)
Set the horizontal gap


setRows

public void setRows(int newRows)
Set the number of rows


setVgap

public void setVgap(int vgap)
Set the vertical gap.


toString

public java.lang.String toString()
Return String description of this object.


getSize

private Dimension getSize(Container parent,
                          boolean is_min)