com.zfqjava.swing
Class CellLayout

java.lang.Object
  |
  +--com.zfqjava.swing.CellLayout
All Implemented Interfaces:
java.awt.LayoutManager, java.awt.LayoutManager2, java.io.Serializable

public class CellLayout
extends java.lang.Object
implements java.awt.LayoutManager2, java.io.Serializable

CellLayout provides a cell layout.

Use JComponent.setAlignmentX and JComponent.setAlignmentY to control the component alignment in specified cell.
Use FillMode to control the component fill mode.
Use CellLayout.Constraints to control the component cell location, and cell span.

See Also:
Serialized Form

Inner Class Summary
static class CellLayout.Constraints
          The CellLayout Constraints.
 
Constructor Summary
CellLayout(int row, int col)
          Constructs a CellLayout use the specified row and column.
CellLayout(int row, int col, int hgap, int vgap)
          Constructs a CellLayout use the specified row and column and default horizontal gap and vertical gap.
 
Method Summary
 void addLayoutComponent(java.awt.Component comp, java.lang.Object constraints)
          Adds the specified component to the layout, using the specified constraint object.
 void addLayoutComponent(java.lang.String name, java.awt.Component comp)
          If the layout manager uses a per-component string, adds the component comp to the layout, associating it with the string specified by name.
 int getColumns()
          Returns the number of columns in this layout.
 double getColumnWeight(int column)
          Returns the weight at the specify column.
 int getHgap(int index)
          Returns the horizontal gap at the specified index.
 float getLayoutAlignmentX(java.awt.Container parent)
          Returns the alignment along the x axis.
 float getLayoutAlignmentY(java.awt.Container parent)
          Returns the alignment along the y axis.
 int getRows()
          Returns the number of rows in this layout.
 double getRowWeight(int row)
          Returns the weight at the specify row.
 int getVgap(int index)
          Returns the vertical gap at the specified index.
 void invalidateLayout(java.awt.Container parent)
          Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.
 void layoutContainer(java.awt.Container parent)
          Lays out the specified container.
 java.awt.Dimension maximumLayoutSize(java.awt.Container parent)
          Calculates the maximum size dimensions for the specified container, given the components it contains.
 java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
          Calculates the minimum size dimensions for the specified container, given the components it contains.
 java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
          Calculates the preferred size dimensions for the specified container, given the components it contains.
 void removeLayoutComponent(java.awt.Component comp)
          Removes the specified component from the layout.
 void setColumns(int cols)
          Sets the number of columns in this layout to the spefified value.
 void setColumnWeight(int column, double weight)
          Sets the weight at the specify column.
 void setHgap(int index, int gap)
          Sets the horizontal gap at the specified index.
 void setRows(int rows)
          Sets the number of rows in this layout to the specified value.
 void setRowWeight(int row, double weight)
          Sets the weight at the specify row.
 void setVgap(int index, int gap)
          Sets the vertical gap at the specified index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CellLayout

public CellLayout(int row,
                  int col)
Constructs a CellLayout use the specified row and column.
Parameters:
row - the row number
col - the column number

CellLayout

public CellLayout(int row,
                  int col,
                  int hgap,
                  int vgap)
Constructs a CellLayout use the specified row and column and default horizontal gap and vertical gap.
Parameters:
row - the row number
col - the column number
hgap - the default horizontal gap
vgap - the default vertical gap
Method Detail

getRows

public int getRows()
Returns the number of rows in this layout.
Returns:
the number of rows in this layout

setRows

public void setRows(int rows)
Sets the number of rows in this layout to the specified value.
Parameters:
rows - the number of rows in this layout

getColumns

public int getColumns()
Returns the number of columns in this layout.
Returns:
the number of columns in this layout

setColumns

public void setColumns(int cols)
Sets the number of columns in this layout to the spefified value.
Parameters:
cols - the number of columns in this layout

setRowWeight

public void setRowWeight(int row,
                         double weight)
Sets the weight at the specify row.
Parameters:
row - the specify row
weight - the weight value
Throws:
java.lang.IndexOutOfBoundsException - if the specify row < 0 || > getRows()-1

getRowWeight

public double getRowWeight(int row)
Returns the weight at the specify row.
Parameters:
row - the specify row
Returns:
the weight value
Throws:
java.lang.IndexOutOfBoundsException - if the specify row < 0 || > getRows()-1

setColumnWeight

public void setColumnWeight(int column,
                            double weight)
Sets the weight at the specify column.
Parameters:
column - the specify column
weight - the weight value
Throws:
java.lang.IndexOutOfBoundsException - if the specify column < 0 || > getColumns()-1

getColumnWeight

public double getColumnWeight(int column)
Returns the weight at the specify column.
Parameters:
column - the specify column
Returns:
the weight value
Throws:
java.lang.IndexOutOfBoundsException - if the specify column < 0 || > getColumns()-1

setHgap

public void setHgap(int index,
                    int gap)
Sets the horizontal gap at the specified index.
Parameters:
index - the horizontal gap index
gap - the gap space to set
Throws:
java.lang.IndexOutOfBoundsException - if the specify index < 0 || > getColumns()-2

getHgap

public int getHgap(int index)
Returns the horizontal gap at the specified index.
Parameters:
index - the horizontal gap index
Returns:
the gap space
Throws:
java.lang.IndexOutOfBoundsException - if the specify index < 0 || > getColumns()-2

setVgap

public void setVgap(int index,
                    int gap)
Sets the vertical gap at the specified index.
Parameters:
index - the vertical gap index
gap - the gap space to set
Throws:
java.lang.IndexOutOfBoundsException - if the specify index < 0 || > getRows()-2

getVgap

public int getVgap(int index)
Returns the vertical gap at the specified index.
Parameters:
index - the vertical gap index
Returns:
the gap space
Throws:
java.lang.IndexOutOfBoundsException - if the specify index < 0 || > getRows()-2

addLayoutComponent

public void addLayoutComponent(java.lang.String name,
                               java.awt.Component comp)
If the layout manager uses a per-component string, adds the component comp to the layout, associating it with the string specified by name.
Specified by:
addLayoutComponent in interface java.awt.LayoutManager
Parameters:
name - the string to be associated with the component
comp - the component to be added

addLayoutComponent

public void addLayoutComponent(java.awt.Component comp,
                               java.lang.Object constraints)
Adds the specified component to the layout, using the specified constraint object.
Specified by:
addLayoutComponent in interface java.awt.LayoutManager2
Parameters:
comp - the component to be added
constraints - where/how the component is added to the layout.

removeLayoutComponent

public void removeLayoutComponent(java.awt.Component comp)
Removes the specified component from the layout.
Specified by:
removeLayoutComponent in interface java.awt.LayoutManager
Parameters:
comp - the component to be removed

preferredLayoutSize

public java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
Calculates the preferred size dimensions for the specified container, given the components it contains.
Specified by:
preferredLayoutSize in interface java.awt.LayoutManager
Parameters:
parent - the container to be laid out
See Also:
minimumLayoutSize(java.awt.Container)

minimumLayoutSize

public java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
Calculates the minimum size dimensions for the specified container, given the components it contains.
Specified by:
minimumLayoutSize in interface java.awt.LayoutManager
Parameters:
parent - the component to be laid out
See Also:
preferredLayoutSize(java.awt.Container)

maximumLayoutSize

public java.awt.Dimension maximumLayoutSize(java.awt.Container parent)
Calculates the maximum size dimensions for the specified container, given the components it contains.
Specified by:
maximumLayoutSize in interface java.awt.LayoutManager2
See Also:
Component.getMaximumSize(), LayoutManager

getLayoutAlignmentX

public float getLayoutAlignmentX(java.awt.Container parent)
Returns the alignment along the x axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.
Specified by:
getLayoutAlignmentX in interface java.awt.LayoutManager2

getLayoutAlignmentY

public float getLayoutAlignmentY(java.awt.Container parent)
Returns the alignment along the y axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.
Specified by:
getLayoutAlignmentY in interface java.awt.LayoutManager2

invalidateLayout

public void invalidateLayout(java.awt.Container parent)
Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.
Specified by:
invalidateLayout in interface java.awt.LayoutManager2

layoutContainer

public void layoutContainer(java.awt.Container parent)
Lays out the specified container.
Specified by:
layoutContainer in interface java.awt.LayoutManager
Parameters:
parent - the container to be laid out


Copyright © 2001-2003 Extreme Component, Inc. All rights reserved.