|
Class UIGridBagConstraints
public class UIGridBagConstraints implements Cloneable
{
// Fields
public int anchor;
public static final int BOTH;
public static final int CENTER;
public static final int EAST;
public int fill;
public int gridheight;
public int gridwidth;
public int gridx;
public int gridy;
public static final int HORIZONTAL;
public Insets insets;
public int ipadx, ipady;
public static final int NONE;
public static final int NORTH;
public static final int NORTHEAST;
public static final int NORTHWEST;
public static final int RELATIVE;
public static final int REMAINDER;
public static final int SOUTH;
public static final int SOUTHEAST;
public static final int SOUTHWEST;
public static final int VERTICAL;
public double weightx;
public double weighty;
public static final int WEST;
// Constructors
public UIGridBagConstraints ();
public UIGridBagConstraints( GridBagConstraints c);
// Methods
public Object clone ();
static public Point getOffsetFromAnchor(Dimension container,
Dimension dim, int anchor);
}
This class is used to specify constraint values for components laid out using the UIGridBagLayout class.
public UIGridBagConstraints ();
Sets the UIGridBagConstraints values to the default values as shown in the following table.
gridz
|
0
|
gridy
|
0
|
gridwidth
|
1
|
gridheight
|
1
|
weightx
|
0
|
weighty
|
0
|
ipadx
|
0
|
ipady
|
0
|
public UIGridBagConstraints( GridBagConstraints c);
Constructs a UIGridBagConstraints object using the information in a UIGridBagConstraints.
- Comments:
- This constructor sets the following variables to UIGridBagConstraints values.
gridx
|
c.gridx
|
gridy
|
c.gridy
|
gridwidth
|
c.gridwidth
|
gridheight
|
c.gridheight
|
weightx
|
c.gridweight
|
weighty
|
c.weighty
|
ipadx
|
c.ipadx
|
ipady
|
c.ipady
|
Parameter | Description |
c
| The UIGridBagConstraints object.
|
See Also: UIGridBagConstraints
public Object clone ();
Clones a copy of the UIGridBagConstraints.
Return Value: Returns a copy of the UIGridBagConstraints object.
Exceptions: InternalError,
but this exception should not occur. This object can be cloned.
static public Point getOffsetFromAnchor(Dimension container, Dimension dim,
int anchor);
Calculates an object's x and y offsets from the anchor, given the containing rectangle and the size of the component to place. This method returns the coordinates for the top left of the component, relative to the anchor. For example, the following would return (70,80).
getOffsetFromAnchor(new Dimension(100,100), new Dimension (30,20)
SOUTHEAST);
Return Value: Returns a point object containing the x and y offsets from the anchor.
Parameter | Description |
container
| The container.
| dim
| The dimensions of the object.
| anchor
| The object's location within the container. Allowable values for anchor are as follows:
|
- anchor
- Specifies the location in the component where the component is placed.
- Comments:
- Possible values for the anchor parameter are as follows:
- BOTH
- A value used to describe the direction the object can grow in to fill the container. The object can grow in the following directions: NONE, HORIZONTAL, or VERTICAL.
- CENTER
- Anchors the component in the CENTER of the component.
- EAST
- Anchors the component in the EAST edge of the component.
- fill
- Specifies the direction the component can grow.
- gridheight
- The height (in pixels) of the component in cells. Used with REMAINDER and gridwidth.
- gridwidth
- The width (in pixels) of the component in cells. Used with REMAINDER and gridheight.
- gridx
- The component's vertical, or row, location on the grid. Used with gridy and relative.
- gridy
- The component's horizontal, or column, location on the grid. Used with gridx and relative.
- HORIZONTAL
- A value used to describe the direction the object can grow in to fill the container. The width is set to the width of the column.
- insets
- This object defines the margins.
- ipadx
- Not Supported.
- ipady
- Not Supported.
- NONE
- A value used to describe the direction the object can grow in to fill the container. This value specifies no fill; instead, getPreferredSize is used.
- NORTH
- Anchors the component in the NORTH end of the component.
- NORTHEAST
- Anchors the component in the NORTHEAST corner of the component.
- NORTHWEST
- Anchors the component in the NORTHWEST corner of the component.
- RELATIVE
- Specifies the location of gridx or gridy relative to the adjacent gridx or gridy component.
- REMAINDER
- Specifies that this is the last component to be added. This component will receive the remaining cells. Used in conjunction with gridwidth or gridheight.
- SOUTH
- Anchors the component in the SOUTH edge of the component.
- SOUTHEAST
- Anchors the component in the SOUTHEAST corner of the component.
- SOUTHWEST
- Anchors the component in the SOUTHWEST corner of the component.
- VERTICAL
- A value used to describe the direction the object can grow in to fill the container. The height is set to the height of the row.
- weightx
- Used to distribute extra horizontal space in a container.
- Comments:
- Each component in a container can ask for a percentage of the extra space by setting weightx to a decimal equivalent of a percentage. The weights are normalized, that is, they are divided among the components that request to be weighted. For example, if 70 pixels were available and only one component set its weightx to .5, that component would receive all 70 pixels. If two components set their weightx to .5, each would receive 35 pixels (half of 70).
- weighty
- Used to distribute extra vertical space in a container.
- Comments:
- Each component in a container can ask for a percentage of the extra space by setting weighty to a decimal equivalent of the percentage needed. The weights are normalized, that is, they are divided among the components that request to be weighted. For example, if 70 pixels were available and only one component set its weighty to .5, that component would receive all 70 pixels. If two components set their weighty to .5, each would receive 35 pixels (half of 70).
- WEST
- Anchors the component in the WEST edge of the component.
|