Packages  This Package  Prev  Next  Index  

§1.21 Class GridBagConstraints

public  class  java.awt.GridBagConstraints
    extends  java.lang.Object  (I-§1.12)
    implements java.lang.Cloneable  (I-§1.22)
{
        // Fields
    public int anchor;	§1.21.1
    public int fill;	§1.21.2
    public int gridheight;	§1.21.3
    public int gridwidth;	§1.21.4
    public int gridx;	§1.21.5
    public int gridy;	§1.21.6
    public Insets insets;	§1.21.7
    public int ipadx;	§1.21.8
    public int ipady;	§1.21.9
    public double weightx;	§1.21.10
    public double weighty;	§1.21.11

        // the anchor field has one of the following values	
    public final static int CENTER;	§1.21.12
    public final static int EAST;	§1.21.13
    public final static int NORTH;	§1.21.14
    public final static int NORTHEAST;	§1.21.15
    public final static int NORTHWEST;	§1.21.16
    public final static int SOUTH;	§1.21.17
    public final static int SOUTHEAST;	§1.21.18
    public final static int SOUTHWEST;	§1.21.19
    public final static int WEST;	§1.21.20

        // the fill field has one of the following values	
    public final static int BOTH;	§1.21.21
    public final static int HORIZONTAL;	§1.21.22
    public final static int NONE;	§1.21.23
    public final static int VERTICAL;	§1.21.24

        // default value for gridheight, gridwidth
    public final static int REMAINDER;	§1.21.25

        // default value for gridx, gridy
    public final static int RELATIVE;	§1.21.26

        // Constructors
    public GridBagConstraints();	§1.21.27

        // Methods
    public Object clone();	§1.21.28
}
The GridBagConstraints class specifies constraints for components that are laid out using the GridBagLayout class (II-§1.22).


Fields

anchor

public int anchor
This field is used when the component is smaller than its display area. It determines where, within the area, to place the component. Valid values are the following:
GridBagConstraints.CENTER
GridBagConstraints.NORTH
GridBagConstraints.NORTHEAST
GridBagConstraints.EAST
GridBagConstraints.SOUTHEAST
GridBagConstraints.SOUTH
GridBagConstraints.SOUTHWEST
GridBagConstraints.WEST
GridBagConstraints.NORTHWEST
The default value is GridBagConstraints.CENTER.

fill

public int fill
This field is used when the component's display area is larger than the component's requested size. It determine whether to resize the component, and if so, how.
Valid values are the following:
The default value is GridBagConstraint.NONE.

gridheight

public int gridheight
Specifies the number of cells in a column for the component's display area.
Use GridBagConstraints.REMAINDER to specify that the component be the last one in its column. Use GridBagConstraints.RELATIVE to specify that the component be the next to last one in its column.
The default value is 1.

gridwidth

public int gridwidth
Specifies the number of cells in a row for the the component's display area.
Use GridBagConstraints.REMAINDER to specify that the component be the last one in its row. Use GridBagConstraints.RELATIVE to specify that the component be the next to last one in its row.
The default value is 1.

gridx

public int gridx
Specifies the cell at the left of the component's display area, where the leftmost cell has gridx = 0. The value GridBagConstraints.RELATIVE specifies that the component be placed just to the right of the component that was added to the container just before this component was added.
The default value is GridBagConstraints.Relative.

gridy

public int gridy
Specifies the cell at the top of the component's display area, where the topmost cell has gridy = 0. The value GridBagConstraints.RELATIVE specifies that the component be placed just below the component that was added to the container just before this component was added.
The default value is GridBagConstraints.Relative.

insets

public Insets insets
This field specifies the external padding of the component, the minimum amount of space between the component and the edges of its display area.
The default value is new Insets(0, 0, 0, 0);

ipadx

public int ipadx
This field specifies the internal padding, that is how much space to add to the minimum size of the component. The width of the component is at least its minimum width plus ipadx*2 pixels.
The default value is 0.

ipady

public int ipady
This field specifies the internal padding, how much to add to the minimum size of the component. The height of the component is at least its minimum height plus ipadx*2 pixels.
The default value is 0.

weightx

public double weightx
This field specifies how to distribute extra vertical space.
The grid bag layout manager calculates the weight of a row to be the maximum weightx of all the components in a row. If the resulting layout is smaller vertically than the area it needs to fill, the extra space is distributed to each row in proportion to its weight. A row that has weight 0 receives no extra space.
If all the weights are zero, all the extra space appears between the grids of the cell and the top and bottom edges.
The default value of this field is zero.

weighty

public double weighty
This field specified how to distribute extra horizontal space.
The grid bag layout manager calculates the weight of a column to be the maximum weighty of all the components in a row. If the resulting layout is smaller horizontally than the area it needs to fill, the extra space is distributed to each column in proportion to its weight. A column that has weight 0 receives no extra space.
If all the weights are zero, all the extra space appears between the grids of the cell and the right and left edges.
The default value of this field is zero.

CENTER

public final static int CENTER = 10
Put the component in the center of its display area.

EAST

public final static int EAST = 13
Put the component on the right side of its display area, centered vertically.

NORTH

public final static int NORTH = 11
Put the component in the top of its display area, centered horizontally

NORTHEAST

public final static int NORTHEAST = 12
Put the component in the top right corner of its display area.

NORTHWEST

public final static int NORTHWEST = 18
Put the component in the top left corner of its display area.

SOUTH

public final static int SOUTH = 15
Put the component in the bottom of its display area, centered horizontally

SOUTHEAST

public final static int SOUTHEAST = 14
Put the component in the bottom right corner of its display area.

SOUTHWEST

public final static int SOUTHWEST = 16
Put the component in the bottom left corner of its display area.

WEST

public final static int WEST = 17
Put the component on the left side of its display area, centered vertically.

BOTH

public final static int BOTH = 1
Resize the component both horizontally and vertically.

HORIZONTAL

public final static int HORIZONTAL = 2
Resize the component horizontally but not vertically.

NONE

public final static int NONE = 0
Do not resize the component.

VERTICAL

public final static int VERTICAL = 3
Resize the component vertically but not horizontally.

REMAINDER

public final static int REMAINDER = 0
Specify that the component is the last component in its column or row.

RELATIVE

public final static int RELATIVE = -1
Specify that this component is the next to last component in its column or row (gridwidth, gridheight), or that this component be placed next to the previously added component (gridx, gridy).

Constructors

GridBagConstraints

public GridBagConstraints()
Creates a grid bag constraint object with all the fields set to their default value.

Methods

clone

public Object clone()
Returns:
a copy of this grid bag constraint.
Overrides:
clone in class Object (I-§1.12.2).

Packages  This Package  Prev  Next  Index
Java API Document (HTML generated by dkramer on April 22, 1996)
Copyright © 1996 Sun Microsystems, Inc. All rights reserved
Please send any comments or corrections to doug.kramer@sun.com