java.awt
Class GridBagLayout

java.lang.Object
  extended by java.awt.GridBagLayout
All Implemented Interfaces:
LayoutManager, LayoutManager2, Serializable

public class GridBagLayout
extends Object
implements Serializable, LayoutManager2

See Also:
Serialized Form

Field Summary
 double[] columnWeights
           
 int[] columnWidths
           
protected  Hashtable<Component,GridBagConstraints> comptable
           
protected  GridBagConstraints defaultConstraints
           
protected  java.awt.GridBagLayoutInfo layoutInfo
           
protected static int MAXGRIDSIZE
           
protected static int MINSIZE
           
protected static int PREFERREDSIZE
           
 int[] rowHeights
           
 double[] rowWeights
           
 
Constructor Summary
GridBagLayout()
           
 
Method Summary
 void addLayoutComponent(Component component, Object constraints)
          Adds the specified component to the layout, with the specified constraints object.
 void addLayoutComponent(String name, Component component)
          Adds the specified component to the layout group.
protected  void adjustForGravity(GridBagConstraints constraints, Rectangle r)
          Move and resize a rectangle according to a set of grid bag constraints.
protected  void AdjustForGravity(GridBagConstraints constraints, Rectangle r)
          Move and resize a rectangle according to a set of grid bag constraints.
protected  void arrangeGrid(Container parent)
           
protected  void ArrangeGrid(Container parent)
          Obsolete.
 GridBagConstraints getConstraints(Component component)
           
 float getLayoutAlignmentX(Container target)
          Returns the preferred X axis alignment for the specified target container.
 float getLayoutAlignmentY(Container target)
          Returns the preferred Y axis alignment for the specified target container.
 int[][] getLayoutDimensions()
           
protected  java.awt.GridBagLayoutInfo getLayoutInfo(Container parent, int sizeflag)
           
protected  java.awt.GridBagLayoutInfo GetLayoutInfo(Container parent, int sizeflag)
          Obsolete.
 Point getLayoutOrigin()
           
 double[][] getLayoutWeights()
           
protected  Dimension getMinSize(Container parent, java.awt.GridBagLayoutInfo info)
           
protected  Dimension GetMinSize(Container parent, java.awt.GridBagLayoutInfo info)
          Obsolete.
 void invalidateLayout(Container target)
          Forces the layout manager to purge any cached information about the layout of the target container.
 void layoutContainer(Container parent)
          Lays out the components in the given container.
 Point location(int x, int y)
           
protected  GridBagConstraints lookupConstraints(Component component)
           
 Dimension maximumLayoutSize(Container target)
          Determines the maximum size of the specified target container.
 Dimension minimumLayoutSize(Container parent)
          Calculates the minimum size for this container, taking into account the components it contains.
 Dimension preferredLayoutSize(Container parent)
          Calculates the preferred size for this container, taking into account the components it contains.
 void removeLayoutComponent(Component component)
          Removes the specified component from the layout group.
 void setConstraints(Component component, GridBagConstraints constraints)
           
 String toString()
          Return a string representation of this GridBagLayout.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MINSIZE

protected static final int MINSIZE
See Also:
Constant Field Values

PREFERREDSIZE

protected static final int PREFERREDSIZE
See Also:
Constant Field Values

MAXGRIDSIZE

protected static final int MAXGRIDSIZE
See Also:
Constant Field Values

comptable

protected Hashtable<Component,GridBagConstraints> comptable

layoutInfo

protected java.awt.GridBagLayoutInfo layoutInfo

defaultConstraints

protected GridBagConstraints defaultConstraints

columnWeights

public double[] columnWeights

columnWidths

public int[] columnWidths

rowWeights

public double[] rowWeights

rowHeights

public int[] rowHeights
Constructor Detail

GridBagLayout

public GridBagLayout()
Method Detail

addLayoutComponent

public void addLayoutComponent(String name,
                               Component component)
Description copied from interface: LayoutManager
Adds the specified component to the layout group.

Specified by:
addLayoutComponent in interface LayoutManager
Parameters:
name - the name of the component to add
component - the component to add

removeLayoutComponent

public void removeLayoutComponent(Component component)
Description copied from interface: LayoutManager
Removes the specified component from the layout group.

Specified by:
removeLayoutComponent in interface LayoutManager
Parameters:
component - the component to remove

addLayoutComponent

public void addLayoutComponent(Component component,
                               Object constraints)
Description copied from interface: LayoutManager2
Adds the specified component to the layout, with the specified constraints object.

Specified by:
addLayoutComponent in interface LayoutManager2
Parameters:
component - the component to add
constraints - the constraints to satisfy

preferredLayoutSize

public Dimension preferredLayoutSize(Container parent)
Description copied from interface: LayoutManager
Calculates the preferred size for this container, taking into account the components it contains.

Specified by:
preferredLayoutSize in interface LayoutManager
Parameters:
parent - the parent container to lay out
Returns:
the preferred dimensions of this container
See Also:
LayoutManager.minimumLayoutSize(Container)

minimumLayoutSize

public Dimension minimumLayoutSize(Container parent)
Description copied from interface: LayoutManager
Calculates the minimum size for this container, taking into account the components it contains.

Specified by:
minimumLayoutSize in interface LayoutManager
Parameters:
parent - the parent container to lay out
Returns:
the minimum dimensions of this container
See Also:
LayoutManager.preferredLayoutSize(Container)

maximumLayoutSize

public Dimension maximumLayoutSize(Container target)
Description copied from interface: LayoutManager2
Determines the maximum size of the specified target container.

Specified by:
maximumLayoutSize in interface LayoutManager2
Parameters:
target - the container to lay out
Returns:
the maximum size of the container
See Also:
Component.getMaximumSize()

layoutContainer

public void layoutContainer(Container parent)
Description copied from interface: LayoutManager
Lays out the components in the given container.

Specified by:
layoutContainer in interface LayoutManager
Parameters:
parent - the container to lay out

getLayoutAlignmentX

public float getLayoutAlignmentX(Container target)
Description copied from interface: LayoutManager2
Returns the preferred X axis alignment for the specified target container. This value will range from 0 to 1 where 0 is alignment closest to the origin, 0.5 is centered, and 1 is aligned furthest from the origin.

Specified by:
getLayoutAlignmentX in interface LayoutManager2
Parameters:
target - the target container
Returns:
the x-axis alignment preference

getLayoutAlignmentY

public float getLayoutAlignmentY(Container target)
Description copied from interface: LayoutManager2
Returns the preferred Y axis alignment for the specified target container. This value will range from 0 to 1 where 0 is alignment closest to the origin, 0.5 is centered, and 1 is aligned furthest from the origin.

Specified by:
getLayoutAlignmentY in interface LayoutManager2
Parameters:
target - the target container
Returns:
the y-axis alignment preference

invalidateLayout

public void invalidateLayout(Container target)
Description copied from interface: LayoutManager2
Forces the layout manager to purge any cached information about the layout of the target container. This will force it to be recalculated.

Specified by:
invalidateLayout in interface LayoutManager2
Parameters:
target - the target container

setConstraints

public void setConstraints(Component component,
                           GridBagConstraints constraints)

getConstraints

public GridBagConstraints getConstraints(Component component)

lookupConstraints

protected GridBagConstraints lookupConstraints(Component component)

getLayoutOrigin

public Point getLayoutOrigin()
Since:
1.1

getLayoutDimensions

public int[][] getLayoutDimensions()
Since:
1.1

getLayoutWeights

public double[][] getLayoutWeights()

location

public Point location(int x,
                      int y)
Since:
1.1

toString

public String toString()
Return a string representation of this GridBagLayout.

Overrides:
toString in class Object
Returns:
a string representation
See Also:
Object.getClass(), Object.hashCode(), Class.getName(), Integer.toHexString(int)

AdjustForGravity

protected void AdjustForGravity(GridBagConstraints constraints,
                                Rectangle r)
Move and resize a rectangle according to a set of grid bag constraints. The x, y, width and height fields of the rectangle argument are adjusted to the new values.

Parameters:
constraints - position and size constraints
r - rectangle to be moved and resized

ArrangeGrid

protected void ArrangeGrid(Container parent)
Obsolete.


GetLayoutInfo

protected java.awt.GridBagLayoutInfo GetLayoutInfo(Container parent,
                                                   int sizeflag)
Obsolete.


GetMinSize

protected Dimension GetMinSize(Container parent,
                               java.awt.GridBagLayoutInfo info)
Obsolete.


getMinSize

protected Dimension getMinSize(Container parent,
                               java.awt.GridBagLayoutInfo info)
Since:
1.4

arrangeGrid

protected void arrangeGrid(Container parent)
Since:
1.4

getLayoutInfo

protected java.awt.GridBagLayoutInfo getLayoutInfo(Container parent,
                                                   int sizeflag)
Since:
1.4

adjustForGravity

protected void adjustForGravity(GridBagConstraints constraints,
                                Rectangle r)
Move and resize a rectangle according to a set of grid bag constraints. The x, y, width and height fields of the rectangle argument are adjusted to the new values.

Parameters:
constraints - position and size constraints
r - rectangle to be moved and resized
Since:
1.4