java.awt
Class GridLayout
- LayoutManager, 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.
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.
|
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
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.
rows
- Number of rowscols
- Number of columns
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.
rows
- Number of rowscols
- Number of columnshgap
- The horizontal gapvgap
- The vertical gap
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.
- layoutContainer in interface LayoutManager
parent
- The container to lay out
setColumns
public void setColumns(int newCols)
Set the number of columns.
IllegalArgumentException
- If the number of columns is
negative, or if the number of columns is zero and the number
of rows is already 0.
setHgap
public void setHgap(int hgap)
Set the horizontal gap. An Exception is not thrown if hgap <320.
hgap
- The horizontal gap
setRows
public void setRows(int newRows)
Set the number of rows
IllegalArgumentException
- If the number of rows is
negative, or if the number of rows is zero and the number
of columns is already 0.
setVgap
public void setVgap(int vgap)
Set the vertical gap. An Exception is not thrown if vgap <320.
GridLayout.java -- Grid-based layout engine
Copyright (C) 1999, 2000, 2002, 2004 Free Software Foundation
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.