|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.GridLayout
public class GridLayout
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.
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(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. |
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. |
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 |
Constructor Detail |
---|
public GridLayout()
GridLayout
with one row and any number
of columns. Both gaps are set to 0.
public GridLayout(int rows, int cols)
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
IllegalArgumentException
- If rows and columns are both
0, or if either are negativepublic GridLayout(int rows, int cols, int hgap, int vgap)
rows
- Number of rowscols
- Number of columnshgap
- The horizontal gapvgap
- The vertical gap
IllegalArgumentException
- If rows and columns are both
0, if either are negative, or if either gap is negativeMethod Detail |
---|
public void addLayoutComponent(String name, Component comp)
addLayoutComponent
in interface LayoutManager
name
- The name of the component to add.comp
- The component to add.public int getColumns()
public int getHgap()
public int getRows()
public int getVgap()
public void layoutContainer(Container parent)
layoutContainer
in interface LayoutManager
parent
- The container to lay outpublic Dimension minimumLayoutSize(Container cont)
minimumLayoutSize
in interface LayoutManager
cont
- The parent container
LayoutManager.preferredLayoutSize(Container)
public Dimension preferredLayoutSize(Container cont)
preferredLayoutSize
in interface LayoutManager
cont
- The parent container
LayoutManager.minimumLayoutSize(Container)
public void removeLayoutComponent(Component comp)
removeLayoutComponent
in interface LayoutManager
comp
- The component to removepublic void setColumns(int newCols)
newCols
-
IllegalArgumentException
- If the number of columns is
negative, or if the number of columns is zero and the number
of rows is already 0.public void setHgap(int hgap)
hgap
- The horizontal gappublic void setRows(int newRows)
newRows
-
IllegalArgumentException
- If the number of rows is
negative, or if the number of rows is zero and the number
of columns is already 0.public void setVgap(int vgap)
vgap
- The vertical gappublic String toString()
toString
in class Object
Object.getClass()
,
Object.hashCode()
,
Class.getName()
,
Integer.toHexString(int)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |