public class ENHGridLayout extends GridLayout
ENHGridLayout is an improved subclass of GridLayout.
It lays out a grid of rows and columns based on the attributes of the
individual rows and columns. ENHGridLayout
uses the widest element in a column to set the width of that
column, and the tallest element in a row to set the height of
that row.| Modifier and Type | Field and Description |
|---|---|
protected int[] |
col_widths
Array of column widths.
|
protected int |
cols
The number of columns in the layout, as set by the user.
|
protected int |
hgap
The horiztonal gap between items.
|
protected int[] |
row_heights
Array of row heights.
|
protected int |
rows
The number of rows in the layout, as set by the user.
|
static int |
VARIABLE |
protected int |
vgap
The vertical gap between items.
|
| Constructor and Description |
|---|
ENHGridLayout(int rows,
int cols)
Creates a grid layout with the specified number of rows and columns.
|
ENHGridLayout(int rows,
int cols,
int hgap,
int vgap)
Creates a grid layout with the specified rows, columns,
horizontal gap, and vertical gap.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
getGridSizes(Container parent,
boolean min)
Traverses the children and determines row heights and column widths.
|
void |
layoutContainer(Container parent)
Performs the layout of the children.
|
Dimension |
minimumLayoutSize(Container parent)
Returns the minimum dimensions needed to layout the components
contained in the specified panel.
|
Dimension |
preferredLayoutSize(Container parent)
Calculates the preferred size for this layout.
|
protected void |
setBounds(int pos,
int row,
int col,
Component comp,
int x,
int y,
int w,
int h) |
addLayoutComponent, getColumns, getHgap, getRows, getVgap, removeLayoutComponent, setColumns, setHgap, setRows, setVgap, toStringprotected int hgap
protected int vgap
protected int rows
protected int cols
protected int[] row_heights
protected int[] col_widths
public static final int VARIABLE
public ENHGridLayout(int rows,
int cols)
rows - the number of rows in the layoutcols - the number of columns in the layoutpublic ENHGridLayout(int rows,
int cols,
int hgap,
int vgap)
rows - the rows; VARIABLE (0) means 'any number.'cols - the columns; VARIABLE (0) means 'any number.'
Only one of 'rows' and 'cols' can be VARIABLE, not both.hgap - the horizontal gap variablevgap - the vertical gap variableIllegalArgumentException - If the rows and columns are invalid.protected void getGridSizes(Container parent, boolean min)
parent - the component which needs to be laid outmin - if true, the minimum size is used. Otherwise, the preferred size
is used.public Dimension preferredLayoutSize(Container parent)
preferredLayoutSize in interface LayoutManagerpreferredLayoutSize in class GridLayoutparent - the component which needs to be laid outpublic Dimension minimumLayoutSize(Container parent)
minimumLayoutSize in interface LayoutManagerminimumLayoutSize in class GridLayoutparent - the component which needs to be laid outprotected void setBounds(int pos,
int row,
int col,
Component comp,
int x,
int y,
int w,
int h)
public void layoutContainer(Container parent)
layoutContainer in interface LayoutManagerlayoutContainer in class GridLayoutparent - the specified component being laid outCopyright © 2018. All rights reserved.