GridBagLayout

Name

GridBagLayout

[Graphic: Figure from the text]

Description

The GridBagLayout LayoutManager provides the means to layout components in a flexible grid-based display model.

Class Definition

public class java.awt.GridBagLayout extends java.lang.Object implements java.awt.LayoutManager2, java.io.Serializable {
 // Protected Constants protected static final MAXGRIDSIZE; protected static final MINSIZE; protected static final PREFERREDSIZE; // Variables public double columnWeights[];
public int columnWidths[];
public int rowHeights[];
public double rowWeights[]; // Protected Variables protected Hashtable comptable; protected GridBagConstraints defaultConstraints; protected GridBagLayoutInfo layoutInfo; // Constructors public GridBagLayout(); // Instance Methods public void addLayoutComponent (Component comp, Object constraints); public void addLayoutComponent (String name, Component component);
public GridBagConstraints getConstraints (Component component);
public abstract float getLayoutAlignmentX(Container target); public abstract float getLayoutAlignmentY(Container target); public int[][] getLayoutDimensions();
public Point getLayoutOrigin();
public double[][] getLayoutWeights();
public abstract void invalidateLayout(Container target); public void layoutContainer (Container target);
public Point location (int x, int y);
public abstract Dimension maximumLayoutSize(Container target); public Dimension minimumLayoutSize (Container target);
public Dimension preferredLayoutSize (Container target);
public void removeLayoutComponent (Component component);
public void setConstraints (Component component, GridBagConstraints constraints);
public String toString(); // Protected Instance Methods protected void AdjustForGravity (GridBagConstraints constraints, Rectangle r); protected void ArrangeGrid (Container target); protected GridBagLayoutInfo GetLayoutInfo (Container target, int sizeFlag); protected Dimension GetMinSize (Container target, GridBagLayoutInfo info); protected GridBagConstraints lookupConstraints (Component comp);
}

Protected Constants

MAXGRIDSIZE

protected static final MAXGRIDSIZE

Maximum number of rows and columns within container managed by GridBagLayout.

MINSIZE

protected static final MINSIZE

Used for internal sizing purposes.

PREFERREDSIZE

protected static final PREFERREDSIZE

Used for internal sizing purposes.

Variables

columnWeights

public double[] columnWeights

The weightx values of the components in the row with the most elements.

columnWidths

public int[] columnWidths

The width values of the components in the row with the most elements.

rowHeights

public int[] rowHeights

The height values of the components in the column with the most elements.

rowWeights

public double[] rowWeights

The weighty values of the components in the column with the most elements.

Protected Variables

comptable

protected Hashtable comptable

Internal table to manage components.

defaultConstraints

protected GridBagConstraints defaultConstraints

Constraints to use for Components that have none.

layoutInfo

protected GridBagLayoutInfo layoutInfo

Internal information about the GridBagLayout.

Constructors

GridBagLayout

public GridBagLayout()

Instance Methods

addLayoutComponent

public void addLayoutComponent (Component comp, Object constraints)

public void addLayoutComponent (String name, Component component)

getConstraints

public GridBagConstraints getConstraints (Component component)

getLayoutAlignmentX

public abstract float getLayoutAlignmentX (Container target)

getLayoutAlignmentY

public abstract float getLayoutAlignmentY (Container target)

getLayoutDimensions

public int[][] getLayoutDimensions()

getLayoutOrigin

public Point getLayoutOrigin()

getLayoutWeights

public double[][] getLayoutWeights()

invalidateLayout

public abstract void invalidateLayout (Container target)

layoutContainer

public void layoutContainer (Container target)

location

public Point location (int x, int y)

maximumLayoutSize

public abstract Dimension maximumLayoutSize (Container target)

minimumLayoutSize

public Dimension minimumLayoutSize (Container target)

preferredLayoutSize

public Dimension preferredLayoutSize (Container target)

removeLayoutComponent

public void removeLayoutComponent (Component component)

setConstraints

public void setConstraints (Component component, GridBagConstraints constraints)

toString

public String toString()

Protected Instance Methods

AdjustForGravity

protected void AdjustForGravity (GridBagConstraints constraints, Rectangle r)

ArrangeGrid

protected void ArrangeGrid (Container target)

GetLayoutInfo

protected GridBagLayoutInfo GetLayoutInfo (Container target, int sizeFlag)

GetMinSize

protected Dimension GetMinSize (Container target, GridBagLayoutInfo info)

lookupConstraints

protected GridBagConstraints lookupConstraints (Component comp)

See Also

Component, Container, Dimension, GridBagConstraints, Hashtable, LayoutManager, LayoutManager2, Object, Point, Rectangle, String