1 /*
2 * Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
105 * <dt>{@link GridBagConstraints#ipadx},
106 * {@link GridBagConstraints#ipady}
107 * <dd>Specifies the component's internal padding within the layout,
108 * how much to add to the minimum size of the component.
109 * The width of the component will be at least its minimum width
110 * plus {@code ipadx} pixels. Similarly, the height of
111 * the component will be at least the minimum height plus
112 * {@code ipady} pixels.
113 * <dt>{@link GridBagConstraints#insets}
114 * <dd>Specifies the component's external padding, the minimum
115 * amount of space between the component and the edges of its display area.
116 * <dt>{@link GridBagConstraints#anchor}
117 * <dd>Specifies where the component should be positioned in its display area.
118 * There are three kinds of possible values: absolute, orientation-relative,
119 * and baseline-relative
120 * Orientation relative values are interpreted relative to the container's
121 * {@code ComponentOrientation} property while absolute values
122 * are not. Baseline relative values are calculated relative to the
123 * baseline. Valid values are:
124 *
125 * <center><table BORDER=0 WIDTH=800
126 * SUMMARY="absolute, relative and baseline values as described above">
127 * <tr>
128 * <th><P style="text-align:left">Absolute Values</th>
129 * <th><P style="text-align:left">Orientation Relative Values</th>
130 * <th><P style="text-align:left">Baseline Relative Values</th>
131 * </tr>
132 * <tr>
133 * <td>
134 * <ul style="list-style-type:none">
135 * <li>{@code GridBagConstraints.NORTH}</li>
136 * <li>{@code GridBagConstraints.SOUTH}</li>
137 * <li>{@code GridBagConstraints.WEST}</li>
138 * <li>{@code GridBagConstraints.EAST}</li>
139 * <li>{@code GridBagConstraints.NORTHWEST}</li>
140 * <li>{@code GridBagConstraints.NORTHEAST}</li>
141 * <li>{@code GridBagConstraints.SOUTHWEST}</li>
142 * <li>{@code GridBagConstraints.SOUTHEAST}</li>
143 * <li>{@code GridBagConstraints.CENTER} (the default)</li>
144 * </ul>
145 * </td>
181 * the {@code GridBagLayout} object puts any extra space
182 * between its grid of cells and the edges of the container.
183 * </dl>
184 * <p>
185 * Each row may have a baseline; the baseline is determined by the
186 * components in that row that have a valid baseline and are aligned
187 * along the baseline (the component's anchor value is one of {@code
188 * BASELINE}, {@code BASELINE_LEADING} or {@code BASELINE_TRAILING}).
189 * If none of the components in the row has a valid baseline, the row
190 * does not have a baseline.
191 * <p>
192 * If a component spans rows it is aligned either to the baseline of
193 * the start row (if the baseline-resize behavior is {@code
194 * CONSTANT_ASCENT}) or the end row (if the baseline-resize behavior
195 * is {@code CONSTANT_DESCENT}). The row that the component is
196 * aligned to is called the <em>prevailing row</em>.
197 * <p>
198 * The following figure shows a baseline layout and includes a
199 * component that spans rows:
200 * <center><table summary="Baseline Layout">
201 * <tr ALIGN=CENTER>
202 * <td>
203 * <img src="doc-files/GridBagLayout-baseline.png"
204 * alt="The following text describes this graphic (Figure 1)." style="float:center">
205 * </td>
206 * </table></center>
207 * This layout consists of three components:
208 * <ul><li>A panel that starts in row 0 and ends in row 1. The panel
209 * has a baseline-resize behavior of {@code CONSTANT_DESCENT} and has
210 * an anchor of {@code BASELINE}. As the baseline-resize behavior
211 * is {@code CONSTANT_DESCENT} the prevailing row for the panel is
212 * row 1.
213 * <li>Two buttons, each with a baseline-resize behavior of
214 * {@code CENTER_OFFSET} and an anchor of {@code BASELINE}.
215 * </ul>
216 * Because the second button and the panel share the same prevailing row,
217 * they are both aligned along their baseline.
218 * <p>
219 * Components positioned using one of the baseline-relative values resize
220 * differently than when positioned using an absolute or orientation-relative
221 * value. How components change is dictated by how the baseline of the
235 * <li>Resizable components positioned on the baseline with a
236 * baseline-resize behavior of {@code OTHER} are only resized if
237 * the baseline at the resized size fits within the display area. If
238 * the baseline is such that it does not fit within the display area
239 * the component is not resized.
240 * <li>Components positioned on the baseline that do not have a
241 * baseline-resize behavior of {@code OTHER}
242 * can only grow as tall as {@code display height - baseline + baseline of component}.
243 * </ul>
244 * If you position a component along the baseline, but the
245 * component does not have a valid baseline, it will be vertically centered
246 * in its space. Similarly if you have positioned a component relative
247 * to the baseline and none of the components in the row have a valid
248 * baseline the component is vertically centered.
249 * <p>
250 * The following figures show ten components (all buttons)
251 * managed by a grid bag layout. Figure 2 shows the layout for a horizontal,
252 * left-to-right container and Figure 3 shows the layout for a horizontal,
253 * right-to-left container.
254 *
255 * <center><table WIDTH=600 summary="layout">
256 * <tr ALIGN=CENTER>
257 * <td>
258 * <img src="doc-files/GridBagLayout-1.gif" alt="The preceding text describes this graphic (Figure 1)." style="float:center; margin: 7px 10px;">
259 * </td>
260 * <td>
261 * <img src="doc-files/GridBagLayout-2.gif" alt="The preceding text describes this graphic (Figure 2)." style="float:center; margin: 7px 10px;">
262 * </td>
263 * <tr ALIGN=CENTER>
264 * <td>Figure 2: Horizontal, Left-to-Right</td>
265 * <td>Figure 3: Horizontal, Right-to-Left</td>
266 * </tr>
267 * </table></center>
268 * <p>
269 * Each of the ten components has the {@code fill} field
270 * of its associated {@code GridBagConstraints} object
271 * set to {@code GridBagConstraints.BOTH}.
272 * In addition, the components have the following non-default constraints:
273 *
274 * <ul>
275 * <li>Button1, Button2, Button3: <code>weightx = 1.0</code>
276 * <li>Button4: <code>weightx = 1.0</code>,
277 * <code>gridwidth = GridBagConstraints.REMAINDER</code>
278 * <li>Button5: <code>gridwidth = GridBagConstraints.REMAINDER</code>
279 * <li>Button6: <code>gridwidth = GridBagConstraints.RELATIVE</code>
280 * <li>Button7: <code>gridwidth = GridBagConstraints.REMAINDER</code>
281 * <li>Button8: <code>gridheight = 2</code>,
282 * <code>weighty = 1.0</code>
283 * <li>Button9, Button 10:
|
1 /*
2 * Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
105 * <dt>{@link GridBagConstraints#ipadx},
106 * {@link GridBagConstraints#ipady}
107 * <dd>Specifies the component's internal padding within the layout,
108 * how much to add to the minimum size of the component.
109 * The width of the component will be at least its minimum width
110 * plus {@code ipadx} pixels. Similarly, the height of
111 * the component will be at least the minimum height plus
112 * {@code ipady} pixels.
113 * <dt>{@link GridBagConstraints#insets}
114 * <dd>Specifies the component's external padding, the minimum
115 * amount of space between the component and the edges of its display area.
116 * <dt>{@link GridBagConstraints#anchor}
117 * <dd>Specifies where the component should be positioned in its display area.
118 * There are three kinds of possible values: absolute, orientation-relative,
119 * and baseline-relative
120 * Orientation relative values are interpreted relative to the container's
121 * {@code ComponentOrientation} property while absolute values
122 * are not. Baseline relative values are calculated relative to the
123 * baseline. Valid values are:
124 *
125 * <center><table BORDER=0 style="width:800"
126 * SUMMARY="absolute, relative and baseline values as described above">
127 * <tr>
128 * <th><P style="text-align:left">Absolute Values</th>
129 * <th><P style="text-align:left">Orientation Relative Values</th>
130 * <th><P style="text-align:left">Baseline Relative Values</th>
131 * </tr>
132 * <tr>
133 * <td>
134 * <ul style="list-style-type:none">
135 * <li>{@code GridBagConstraints.NORTH}</li>
136 * <li>{@code GridBagConstraints.SOUTH}</li>
137 * <li>{@code GridBagConstraints.WEST}</li>
138 * <li>{@code GridBagConstraints.EAST}</li>
139 * <li>{@code GridBagConstraints.NORTHWEST}</li>
140 * <li>{@code GridBagConstraints.NORTHEAST}</li>
141 * <li>{@code GridBagConstraints.SOUTHWEST}</li>
142 * <li>{@code GridBagConstraints.SOUTHEAST}</li>
143 * <li>{@code GridBagConstraints.CENTER} (the default)</li>
144 * </ul>
145 * </td>
181 * the {@code GridBagLayout} object puts any extra space
182 * between its grid of cells and the edges of the container.
183 * </dl>
184 * <p>
185 * Each row may have a baseline; the baseline is determined by the
186 * components in that row that have a valid baseline and are aligned
187 * along the baseline (the component's anchor value is one of {@code
188 * BASELINE}, {@code BASELINE_LEADING} or {@code BASELINE_TRAILING}).
189 * If none of the components in the row has a valid baseline, the row
190 * does not have a baseline.
191 * <p>
192 * If a component spans rows it is aligned either to the baseline of
193 * the start row (if the baseline-resize behavior is {@code
194 * CONSTANT_ASCENT}) or the end row (if the baseline-resize behavior
195 * is {@code CONSTANT_DESCENT}). The row that the component is
196 * aligned to is called the <em>prevailing row</em>.
197 * <p>
198 * The following figure shows a baseline layout and includes a
199 * component that spans rows:
200 * <center><table summary="Baseline Layout">
201 * <tr style="text-align:center">
202 * <td>
203 * <img src="doc-files/GridBagLayout-baseline.png"
204 * alt="The following text describes this graphic (Figure 1)." style="float:center">
205 * </td>
206 * </table></center>
207 * This layout consists of three components:
208 * <ul><li>A panel that starts in row 0 and ends in row 1. The panel
209 * has a baseline-resize behavior of {@code CONSTANT_DESCENT} and has
210 * an anchor of {@code BASELINE}. As the baseline-resize behavior
211 * is {@code CONSTANT_DESCENT} the prevailing row for the panel is
212 * row 1.
213 * <li>Two buttons, each with a baseline-resize behavior of
214 * {@code CENTER_OFFSET} and an anchor of {@code BASELINE}.
215 * </ul>
216 * Because the second button and the panel share the same prevailing row,
217 * they are both aligned along their baseline.
218 * <p>
219 * Components positioned using one of the baseline-relative values resize
220 * differently than when positioned using an absolute or orientation-relative
221 * value. How components change is dictated by how the baseline of the
235 * <li>Resizable components positioned on the baseline with a
236 * baseline-resize behavior of {@code OTHER} are only resized if
237 * the baseline at the resized size fits within the display area. If
238 * the baseline is such that it does not fit within the display area
239 * the component is not resized.
240 * <li>Components positioned on the baseline that do not have a
241 * baseline-resize behavior of {@code OTHER}
242 * can only grow as tall as {@code display height - baseline + baseline of component}.
243 * </ul>
244 * If you position a component along the baseline, but the
245 * component does not have a valid baseline, it will be vertically centered
246 * in its space. Similarly if you have positioned a component relative
247 * to the baseline and none of the components in the row have a valid
248 * baseline the component is vertically centered.
249 * <p>
250 * The following figures show ten components (all buttons)
251 * managed by a grid bag layout. Figure 2 shows the layout for a horizontal,
252 * left-to-right container and Figure 3 shows the layout for a horizontal,
253 * right-to-left container.
254 *
255 * <center><table style="width:600" summary="layout">
256 * <tr style="text-align:center">
257 * <td>
258 * <img src="doc-files/GridBagLayout-1.gif" alt="The preceding text describes this graphic (Figure 1)." style="float:center; margin: 7px 10px;">
259 * </td>
260 * <td>
261 * <img src="doc-files/GridBagLayout-2.gif" alt="The preceding text describes this graphic (Figure 2)." style="float:center; margin: 7px 10px;">
262 * </td>
263 * <tr style="text-align:center">
264 * <td>Figure 2: Horizontal, Left-to-Right</td>
265 * <td>Figure 3: Horizontal, Right-to-Left</td>
266 * </tr>
267 * </table></center>
268 * <p>
269 * Each of the ten components has the {@code fill} field
270 * of its associated {@code GridBagConstraints} object
271 * set to {@code GridBagConstraints.BOTH}.
272 * In addition, the components have the following non-default constraints:
273 *
274 * <ul>
275 * <li>Button1, Button2, Button3: <code>weightx = 1.0</code>
276 * <li>Button4: <code>weightx = 1.0</code>,
277 * <code>gridwidth = GridBagConstraints.REMAINDER</code>
278 * <li>Button5: <code>gridwidth = GridBagConstraints.REMAINDER</code>
279 * <li>Button6: <code>gridwidth = GridBagConstraints.RELATIVE</code>
280 * <li>Button7: <code>gridwidth = GridBagConstraints.REMAINDER</code>
281 * <li>Button8: <code>gridheight = 2</code>,
282 * <code>weighty = 1.0</code>
283 * <li>Button9, Button 10:
|