JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.util.swing
Class JCGridLayout

java.lang.Object
  |
  +--java.awt.GridLayout
        |
        +--com.klg.jclass.util.swing.JCGridLayout
All Implemented Interfaces:
LayoutManager, Serializable
Direct Known Subclasses:
JCAlignLayout

public class JCGridLayout
extends GridLayout

JCGridLayout 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. Whereas GridLayout uses the widest and tallest child to size each cell, JCGridLayout 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.

See Also:
Serialized Form

Field Summary
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 Summary
JCGridLayout(int rows, int cols)
          Creates a grid layout with the specified number of rows and columns.
JCGridLayout(int rows, int cols, int hgap, int vgap)
          Creates a grid layout with the specified rows, columns, horizontal gap, and vertical gap.
 
Method Summary
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)
          Positions the component.
 
Methods inherited from class java.awt.GridLayout
addLayoutComponent, getColumns, getHgap, getRows, getVgap, removeLayoutComponent, setColumns, setHgap, setRows, setVgap, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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

JCGridLayout

public JCGridLayout(int rows,
                    int cols)
Creates a grid layout with the specified number of rows and columns.

Parameters:
rows - the number of rows in the layout
cols - the number of columns in the layout

JCGridLayout

public JCGridLayout(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.' Only one of 'rows' and 'cols' can be VARIABLE, not both.
cols - the columns; VARIABLE (0) means 'any number.' Only one of 'rows' and 'cols' can be VARIABLE, not both.
hgap - the horizontal gap variable
vgap - the vertical gap variable
Throws:
IllegalArgumentException - If the rows and columns are invalid.
Method Detail

getGridSizes

protected void getGridSizes(Container parent,
                            boolean min)
Traverses the children and determines row heights and column widths.

Parameters:
parent - the component which needs to be laid out
min - if true, the minimum size is used; otherwise, the preferred size is used

preferredLayoutSize

public Dimension preferredLayoutSize(Container parent)
Calculates the preferred size for this layout.

Specified by:
preferredLayoutSize in interface LayoutManager
Overrides:
preferredLayoutSize in class GridLayout
Parameters:
parent - the component which needs to be laid out
Returns:

minimumLayoutSize

public Dimension minimumLayoutSize(Container parent)
Returns the minimum dimensions needed to layout the components contained in the specified panel.

Specified by:
minimumLayoutSize in interface LayoutManager
Overrides:
minimumLayoutSize in class GridLayout
Parameters:
parent - the component which needs to be laid out
Returns:

setBounds

protected void setBounds(int pos,
                         int row,
                         int col,
                         Component comp,
                         int x,
                         int y,
                         int w,
                         int h)
Positions the component.

Parameters:
pos - the component's index in its parents child list
row - component's position (row)
col - component's position (column)
comp -
h -
w -
x -
y -

layoutContainer

public void layoutContainer(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:
layoutContainer in interface LayoutManager
Overrides:
layoutContainer in class GridLayout
Parameters:
parent - the specified component being laid out

Copyright © 2004 Quest Software Inc..
All rights reserved.