Package org.tn5250j.tools
Class ENHGridLayout
- java.lang.Object
-
- java.awt.GridLayout
-
- org.tn5250j.tools.ENHGridLayout
-
- All Implemented Interfaces:
java.awt.LayoutManager,java.io.Serializable
- Direct Known Subclasses:
AlignLayout
public class ENHGridLayout extends java.awt.GridLayoutENHGridLayoutis an improved subclass ofGridLayout. It lays out a grid of rows and columns based on the attributes of the individual rows and columns.ENHGridLayoutuses 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.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected int[]col_widthsArray of column widths.protected intcolsThe number of columns in the layout, as set by the user.protected inthgapThe horiztonal gap between items.protected int[]row_heightsArray of row heights.protected introwsThe number of rows in the layout, as set by the user.static intVARIABLEprotected intvgapThe vertical gap between items.
-
Constructor Summary
Constructors Constructor 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.
-
Method Summary
Modifier and Type Method Description protected voidgetGridSizes(java.awt.Container parent, boolean min)Traverses the children and determines row heights and column widths.voidlayoutContainer(java.awt.Container parent)Performs the layout of the children.java.awt.DimensionminimumLayoutSize(java.awt.Container parent)Returns the minimum dimensions needed to layout the components contained in the specified panel.java.awt.DimensionpreferredLayoutSize(java.awt.Container parent)Calculates the preferred size for this layout.protected voidsetBounds(int pos, int row, int col, java.awt.Component comp, int x, int y, int w, int h)
-
-
-
Field Detail
-
hgap
protected int hgap
The horiztonal gap between items.
-
vgap
protected int vgap
The vertical gap between items.
-
rows
protected int rows
The number of rows in the layout, as set by the user. This number may not correspond exactly to the number of rows in the layout.
-
cols
protected int cols
The number of columns in the layout, as set by the user. This number may not correspond exactly to the number of columns in the layout.
-
row_heights
protected int[] row_heights
Array of row heights. It is accurate only after a call to getGridSizes()
-
col_widths
protected int[] col_widths
Array of column widths. It is accurate only after a call to getGridSizes()
-
VARIABLE
public static final int VARIABLE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ENHGridLayout
public ENHGridLayout(int rows, int cols)Creates a grid layout with the specified number of rows and columns.- Parameters:
rows- the number of rows in the layoutcols- the number of columns in the layout
-
ENHGridLayout
public ENHGridLayout(int rows, int cols, int hgap, int vgap)Creates a grid layout with the specified rows, columns, horizontal gap, and vertical gap.- Parameters:
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 variable- Throws:
java.lang.IllegalArgumentException- If the rows and columns are invalid.
-
-
Method Detail
-
getGridSizes
protected void getGridSizes(java.awt.Container parent, boolean min)Traverses the children and determines row heights and column widths.- Parameters:
parent- the component which needs to be laid outmin- if true, the minimum size is used. Otherwise, the preferred size is used.
-
preferredLayoutSize
public java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
Calculates the preferred size for this layout.- Specified by:
preferredLayoutSizein interfacejava.awt.LayoutManager- Overrides:
preferredLayoutSizein classjava.awt.GridLayout- Parameters:
parent- the component which needs to be laid out
-
minimumLayoutSize
public java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
Returns the minimum dimensions needed to layout the components contained in the specified panel.- Specified by:
minimumLayoutSizein interfacejava.awt.LayoutManager- Overrides:
minimumLayoutSizein classjava.awt.GridLayout- Parameters:
parent- the component which needs to be laid out
-
setBounds
protected void setBounds(int pos, int row, int col, java.awt.Component comp, int x, int y, int w, int h)
-
layoutContainer
public void layoutContainer(java.awt.Container parent)
Performs the layout of the children. It calculates the number of actual rows and columns based on the user's settings, retrieves row height and column width information, then moves all the children to the appropriate places.- Specified by:
layoutContainerin interfacejava.awt.LayoutManager- Overrides:
layoutContainerin classjava.awt.GridLayout- Parameters:
parent- the specified component being laid out
-
-