GridBagConstraints.java revision 3261
3909N/A * Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved. 3448N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3448N/A * This code is free software; you can redistribute it and/or modify it 3448N/A * under the terms of the GNU General Public License version 2 only, as 3448N/A * published by the Free Software Foundation. Oracle designates this 3448N/A * particular file as subject to the "Classpath" exception as provided 3448N/A * by Oracle in the LICENSE file that accompanied this code. 3448N/A * This code is distributed in the hope that it will be useful, but WITHOUT 3448N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 3448N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 3448N/A * version 2 for more details (a copy is included in the LICENSE file that 3448N/A * You should have received a copy of the GNU General Public License version 3448N/A * 2 along with this work; if not, write to the Free Software Foundation, 3448N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 3448N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 3448N/A * or visit www.oracle.com if you need additional information or have any 544N/A * The <code>GridBagConstraints</code> class specifies constraints 544N/A * for components that are laid out using the 544N/A * <code>GridBagLayout</code> class. 544N/A * @author Bill Spitzak (orignial NeWS & OLIT implementation) 544N/A * @see java.awt.GridBagLayout 544N/A * Specifies that this component is the next-to-last component in its 544N/A * column or row (<code>gridwidth</code>, <code>gridheight</code>), 544N/A * or that this component be placed next to the previously added 544N/A * component (<code>gridx</code>, <code>gridy</code>). 544N/A * @see java.awt.GridBagConstraints#gridwidth 544N/A * @see java.awt.GridBagConstraints#gridheight 544N/A * @see java.awt.GridBagConstraints#gridx 544N/A * @see java.awt.GridBagConstraints#gridy 544N/A * Specifies that this component is the 544N/A * last component in its column or row. 544N/A * Do not resize the component. 544N/A * Resize the component both horizontally and vertically. 544N/A * Resize the component horizontally but not vertically. * Resize the component vertically but not horizontally. * Put the component in the center of its display area. public static final int CENTER =
10;
* Put the component at the top of its display area, public static final int NORTH =
11;
* Put the component at the top-right corner of its display area. * Put the component on the right side of its display area, public static final int EAST =
13;
* Put the component at the bottom-right corner of its display area. * Put the component at the bottom of its display area, centered public static final int SOUTH =
15;
* Put the component at the bottom-left corner of its display area. * Put the component on the left side of its display area, public static final int WEST =
17;
* Put the component at the top-left corner of its display area. * Place the component centered along the edge of its display area * associated with the start of a page for the current * {@code ComponentOrientation}. Equal to NORTH for horizontal * Place the component centered along the edge of its display area * associated with the end of a page for the current * {@code ComponentOrientation}. Equal to SOUTH for horizontal * Place the component centered along the edge of its display area where * lines of text would normally begin for the current * {@code ComponentOrientation}. Equal to WEST for horizontal, * left-to-right orientations and EAST for horizontal, right-to-left * Place the component centered along the edge of its display area where * lines of text would normally end for the current * {@code ComponentOrientation}. Equal to EAST for horizontal, * left-to-right orientations and WEST for horizontal, right-to-left * Place the component in the corner of its display area where * the first line of text on a page would normally begin for the current * {@code ComponentOrientation}. Equal to NORTHWEST for horizontal, * left-to-right orientations and NORTHEAST for horizontal, right-to-left * Place the component in the corner of its display area where * the first line of text on a page would normally end for the current * {@code ComponentOrientation}. Equal to NORTHEAST for horizontal, * left-to-right orientations and NORTHWEST for horizontal, right-to-left * Place the component in the corner of its display area where * the last line of text on a page would normally start for the current * {@code ComponentOrientation}. Equal to SOUTHWEST for horizontal, * left-to-right orientations and SOUTHEAST for horizontal, right-to-left * Place the component in the corner of its display area where * the last line of text on a page would normally end for the current * {@code ComponentOrientation}. Equal to SOUTHEAST for horizontal, * left-to-right orientations and SOUTHWEST for horizontal, right-to-left * Possible value for the <code>anchor</code> field. Specifies * that the component should be horizontally centered and * vertically aligned along the baseline of the prevailing row. * If the component does not have a baseline it will be vertically public static final int BASELINE =
0x100;
* Possible value for the <code>anchor</code> field. Specifies * that the component should be horizontally placed along the * leading edge. For components with a left-to-right orientation, * the leading edge is the left edge. Vertically the component is * aligned along the baseline of the prevailing row. If the * component does not have a baseline it will be vertically * Possible value for the <code>anchor</code> field. Specifies * that the component should be horizontally placed along the * trailing edge. For components with a left-to-right * orientation, the trailing edge is the right edge. Vertically * the component is aligned along the baseline of the prevailing * row. If the component does not have a baseline it will be * Possible value for the <code>anchor</code> field. Specifies * that the component should be horizontally centered. Vertically * the component is positioned so that its bottom edge touches * the baseline of the starting row. If the starting row does not * have a baseline it will be vertically centered. * Possible value for the <code>anchor</code> field. Specifies * that the component should be horizontally placed along the * leading edge. For components with a left-to-right orientation, * the leading edge is the left edge. Vertically the component is * positioned so that its bottom edge touches the baseline of the * starting row. If the starting row does not have a baseline it * will be vertically centered. * Possible value for the <code>anchor</code> field. Specifies * that the component should be horizontally placed along the * trailing edge. For components with a left-to-right * orientation, the trailing edge is the right edge. Vertically * the component is positioned so that its bottom edge touches * the baseline of the starting row. If the starting row does not * have a baseline it will be vertically centered. * Possible value for the <code>anchor</code> field. Specifies * that the component should be horizontally centered. Vertically * the component is positioned so that its top edge touches the * baseline of the starting row. If the starting row does not * have a baseline it will be vertically centered. * Possible value for the <code>anchor</code> field. Specifies * that the component should be horizontally placed along the * leading edge. For components with a left-to-right orientation, * the leading edge is the left edge. Vertically the component is * positioned so that its top edge touches the baseline of the * starting row. If the starting row does not have a baseline it * will be vertically centered. * Possible value for the <code>anchor</code> field. Specifies * that the component should be horizontally placed along the * trailing edge. For components with a left-to-right * orientation, the trailing edge is the right edge. Vertically * the component is positioned so that its top edge touches the * baseline of the starting row. If the starting row does not * have a baseline it will be vertically centered. * Specifies the cell containing the leading edge of the component's * display area, where the first cell in a row has <code>gridx=0</code>. * The leading edge of a component's display area is its left edge for * a horizontal, left-to-right container and its right edge for a * horizontal, right-to-left container. * <code>RELATIVE</code> specifies that the component be placed * immediately following the component that was added to the container * just before this component was added. * The default value is <code>RELATIVE</code>. * <code>gridx</code> should be a non-negative value. * @see java.awt.GridBagConstraints#gridy * @see java.awt.ComponentOrientation * Specifies the cell at the top of the component's display area, * where the topmost cell has <code>gridy=0</code>. The value * <code>RELATIVE</code> 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 <code>RELATIVE</code>. * <code>gridy</code> should be a non-negative value. * @see java.awt.GridBagConstraints#gridx * Specifies the number of cells in a row for the component's * Use <code>REMAINDER</code> to specify that the component's * display area will be from <code>gridx</code> to the last * Use <code>RELATIVE</code> to specify that the component's * display area will be from <code>gridx</code> to the next * to the last one in its row. * <code>gridwidth</code> should be non-negative and the default * @see java.awt.GridBagConstraints#gridheight * Specifies the number of cells in a column for the component's * Use <code>REMAINDER</code> to specify that the component's * display area will be from <code>gridy</code> to the last * Use <code>RELATIVE</code> to specify that the component's * display area will be from <code>gridy</code> to the next * to the last one in its column. * <code>gridheight</code> should be a non-negative value and the * @see java.awt.GridBagConstraints#gridwidth * Specifies how to distribute extra horizontal space. * The grid bag layout manager calculates the weight of a column to * be the maximum <code>weightx</code> of all the components in a * column. 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 a weight of zero receives * If all the weights are zero, all the extra space appears between * the grids of the cell and the left and right edges. * The default value of this field is <code>0</code>. * <code>weightx</code> should be a non-negative value. * @see java.awt.GridBagConstraints#weighty * Specifies how to distribute extra vertical space. * The grid bag layout manager calculates the weight of a row to be * the maximum <code>weighty</code> 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 a weight of zero receives no * 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 <code>0</code>. * <code>weighty</code> should be a non-negative value. * @see java.awt.GridBagConstraints#weightx * This field is used when the component is smaller than its * display area. It determines where, within the display area, to * <p> There are three kinds of possible values: orientation * relative, baseline relative and absolute. Orientation relative * values are interpreted relative to the container's component * orientation property, baseline relative values are interpreted * relative to the baseline and absolute values are not. The * <code>CENTER</code>, <code>NORTH</code>, <code>NORTHEAST</code>, * <code>EAST</code>, <code>SOUTHEAST</code>, <code>SOUTH</code>, * <code>SOUTHWEST</code>, <code>WEST</code>, and <code>NORTHWEST</code>. * The orientation relative values are: <code>PAGE_START</code>, * <code>LINE_START</code>, <code>LINE_END</code>, * <code>FIRST_LINE_START</code>, <code>FIRST_LINE_END</code>, * <code>LAST_LINE_START</code> and <code>LAST_LINE_END</code>. The * baseline relative values are: * <code>BASELINE</code>, <code>BASELINE_LEADING</code>, * <code>BASELINE_TRAILING</code>, * <code>ABOVE_BASELINE</code>, <code>ABOVE_BASELINE_LEADING</code>, * <code>ABOVE_BASELINE_TRAILING</code>, * <code>BELOW_BASELINE</code>, <code>BELOW_BASELINE_LEADING</code>, * and <code>BELOW_BASELINE_TRAILING</code>. * The default value is <code>CENTER</code>. * @see java.awt.ComponentOrientation * This field is used when the component's display area is larger * than the component's requested size. It determines whether to * resize the component, and if so, how. * The following values are valid for <code>fill</code>: * <code>NONE</code>: Do not resize the component. * <code>HORIZONTAL</code>: Make the component wide enough to fill * its display area horizontally, but do not change its height. * <code>VERTICAL</code>: Make the component tall enough to fill its * display area vertically, but do not change its width. * <code>BOTH</code>: Make the component fill its display area * The default value is <code>NONE</code>. * This field specifies the external padding of the component, the * minimum amount of space between the component and the edges of its * The default value is <code>new Insets(0, 0, 0, 0)</code>. * This field specifies the internal padding of the component, how much * space to add to the minimum width of the component. The width of * the component is at least its minimum width plus * <code>ipadx</code> pixels. * The default value is <code>0</code>. * @see java.awt.GridBagConstraints#ipady * This field specifies the internal padding, that is, how much * space to add to the minimum height of the component. The height of * the component is at least its minimum height plus * <code>ipady</code> pixels. * The default value is 0. * @see java.awt.GridBagConstraints#ipadx * Temporary place holder for the x coordinate. * Temporary place holder for the y coordinate. * Temporary place holder for the Width of the component. * Temporary place holder for the Height of the component. * The minimum width of the component. It is used to calculate * <code>ipady</code>, where the default will be 0. * The minimum height of the component. It is used to calculate * <code>ipadx</code>, where the default will be 0. // The following fields are only used if the anchor is // one of BASELINE, BASELINE_LEADING or BASELINE_TRAILING. // ascent and descent include the insets and ipady values. // The folllowing two fields are used if the baseline type is // centerPadding is either 0 or 1 and indicates if // the height needs to be padded by one when calculating where the // Where the baseline lands relative to the center of the component. * JDK 1.1 serialVersionUID * Creates a <code>GridBagConstraint</code> object with * all of its fields set to their default value. * Creates a <code>GridBagConstraints</code> object with * all of its fields set to the passed-in arguments. * Note: Because the use of this constructor hinders readability * of source code, this constructor should only be used by * automatic source code generation tools. * @param gridx The initial gridx value. * @param gridy The initial gridy value. * @param gridwidth The initial gridwidth value. * @param gridheight The initial gridheight value. * @param weightx The initial weightx value. * @param weighty The initial weighty value. * @param anchor The initial anchor value. * @param fill The initial fill value. * @param insets The initial insets value. * @param ipadx The initial ipadx value. * @param ipady The initial ipady value. * @see java.awt.GridBagConstraints#gridx * @see java.awt.GridBagConstraints#gridy * @see java.awt.GridBagConstraints#gridwidth * @see java.awt.GridBagConstraints#gridheight * @see java.awt.GridBagConstraints#weightx * @see java.awt.GridBagConstraints#weighty * @see java.awt.GridBagConstraints#anchor * @see java.awt.GridBagConstraints#fill * @see java.awt.GridBagConstraints#insets * @see java.awt.GridBagConstraints#ipadx * @see java.awt.GridBagConstraints#ipady * Creates a copy of this grid bag constraint. * @return a copy of this grid bag constraint // this shouldn't happen, since we are Cloneable