Package java.awt |
![]() Previous |
![]() Java API |
![]() Index |
![]() Next |
public class java.awt.GridBagConstraints extends java.lang.Object implements java.lang.Cloneable { // Fields public int anchor; public int fill; public int gridheight; public int gridwidth; public int gridx; public int gridy; public Insets insets; public int ipadx; public int ipady; public double weightx; public double weighty; // the anchor field has one of the following values public final static int CENTER; public final static int EAST; public final static int NORTH; public final static int NORTHEAST; public final static int NORTHWEST; public final static int SOUTH; public final static int SOUTHEAST; public final static int SOUTHWEST; public final static int WEST; // the fill field has one of the following values public final static int BOTH; public final static int HORIZONTAL; public final static int NONE; public final static int VERTICAL; // default value for gridheight, gridwidth public final static int REMAINDER; // default value for gridx, gridy public final static int RELATIVE; // Constructors public GridBagConstraints(); // Methods public Object clone(); }
The GridBagConstraints class specifies constraints for components that are laid out using the GridBagLayout class .
public int anchorGridBagConstraints.CENTER GridBagConstraints.NORTH GridBagConstraints.NORTHEAST GridBagConstraints.EAST GridBagConstraints.SOUTHEAST GridBagConstraints.SOUTH GridBagConstraints.SOUTHWEST GridBagConstraints.WEST GridBagConstraints.NORTHWESTThis 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:
Remarks:
The default value is GridBagConstraints.CENTER.
public int fillThis 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:
- GridBagConstraint.NONE:Do not resize the component.
- GridBagConstraint.HORIZONTAL: Make the component wide enough to fill its display area horizontally, but don't change its height.
- GridBagConstraint.VERTICAL: Make the component tall enough to fill its display area vertically, but don't change its width.
- GridBagConstraint.BOTH: Make the component fill its display area entirely.
The default value is GridBagConstraint.NONE.
public int gridheightSpecifies 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.
public int gridwidthSpecifies 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.
public int gridxSpecifies 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.
public int gridySpecifies 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.
public Insets insetsThis 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);
public int ipadxThis 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.
public int ipadyThis 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.
public double weightxThis 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.
public double weightyThis 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.
public final static int CENTER = 10Put the component in the center of its display area.
public final static int EAST = 13Put the component on the right side of its display area, centered vertically.
public final static int NORTH = 11Put the component in the top of its display area, centered horizontally
public final static int NORTHEAST = 12Put the component in the top right corner of its display area.
public final static int NORTHWEST = 18Put the component in the top left corner of its display area.
public final static int SOUTH = 15Put the component in the bottom of its display area, centered horizontally
public final static int SOUTHEAST = 14Put the component in the bottom right corner of its display area.
public final static int SOUTHWEST = 16Put the component in the bottom left corner of its display area.
public final static int WEST = 17Put the component on the left side of its display area, centered vertically.
public final static int BOTH = 1Resize the component both horizontally and vertically.
public final static int HORIZONTAL = 2Resize the component horizontally but not vertically.
public final static int NONE = 0Do not resize the component.
public final static int VERTICAL = 3Resize the component vertically but not horizontally.
public final static int REMAINDER = 0Specify that the component is the last component in its column or row.
public final static int RELATIVE = -1Specify 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).
public GridBagConstraints()Creates a grid bag constraint object with all the fields set to their default value.
public Object clone()Return Value:
Returns a copy of this grid bag constraint.
Overrides:
clone in class Object .