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
38 * import java.awt.*;
39 * import java.applet.Applet;
40 * public class ButtonGrid extends Applet {
41 * public void init() {
42 * setLayout(new GridLayout(3,2));
43 * add(new Button("1"));
44 * add(new Button("2"));
45 * add(new Button("3"));
46 * add(new Button("4"));
47 * add(new Button("5"));
48 * add(new Button("6"));
49 * }
50 * }
51 * </pre></blockquote><hr>
52 * <p>
53 * If the container's {@code ComponentOrientation} property is horizontal
54 * and left-to-right, the above example produces the output shown in Figure 1.
55 * If the container's {@code ComponentOrientation} property is horizontal
56 * and right-to-left, the example produces the output shown in Figure 2.
57 *
58 * <table style="float:center;width:600">
59 * <caption style="display:none">Figures</caption>
60 * <tr style="text-align:center">
61 * <td><img SRC="doc-files/GridLayout-1.gif"
62 * alt="Shows 6 buttons in rows of 2. Row 1 shows buttons 1 then 2.
63 * Row 2 shows buttons 3 then 4. Row 3 shows buttons 5 then 6.">
64 * </td>
65 *
66 * <td style="text-align:center"><img SRC="doc-files/GridLayout-2.gif"
67 * alt="Shows 6 buttons in rows of 2. Row 1 shows buttons 2 then 1.
68 * Row 2 shows buttons 4 then 3. Row 3 shows buttons 6 then 5.">
69 * </td>
70 * </tr>
71 *
72 * <tr style="text-align:center">
73 * <td>Figure 1: Horizontal, Left-to-Right</td>
74 *
75 * <td>Figure 2: Horizontal, Right-to-Left</td>
76 * </tr>
77 * </table>
78 * <p>
79 * When both the number of rows and the number of columns have
80 * been set to non-zero values, either by a constructor or
81 * by the {@code setRows} and {@code setColumns} methods, the number of
82 * columns specified is ignored. Instead, the number of
83 * columns is determined from the specified number of rows
84 * and the total number of components in the layout. So, for
85 * example, if three rows and two columns have been specified
86 * and nine components are added to the layout, they will
87 * be displayed as three rows of three columns. Specifying
88 * the number of columns affects the layout only when the
89 * number of rows is set to zero.
90 *
91 * @author Arthur van Hoff
92 * @since 1.0
93 */
94 public class GridLayout implements LayoutManager, java.io.Serializable {
95 /*
96 * serialVersionUID
97 */
|
1 /*
2 * Copyright (c) 1995, 2019, 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
38 * import java.awt.*;
39 * import java.applet.Applet;
40 * public class ButtonGrid extends Applet {
41 * public void init() {
42 * setLayout(new GridLayout(3,2));
43 * add(new Button("1"));
44 * add(new Button("2"));
45 * add(new Button("3"));
46 * add(new Button("4"));
47 * add(new Button("5"));
48 * add(new Button("6"));
49 * }
50 * }
51 * </pre></blockquote><hr>
52 * <p>
53 * If the container's {@code ComponentOrientation} property is horizontal
54 * and left-to-right, the above example produces the output shown in Figure 1.
55 * If the container's {@code ComponentOrientation} property is horizontal
56 * and right-to-left, the example produces the output shown in Figure 2.
57 *
58 * <div style="margin:0 auto;width:600px;text-align:center;font-weight:bold">
59 * <div style="float:left">
60 * <p><img SRC="doc-files/GridLayout-1.gif"
61 * alt="Shows 6 buttons in rows of 2. Row 1 shows buttons 1 then 2.
62 * Row 2 shows buttons 3 then 4. Row 3 shows buttons 5 then 6.">
63 * <p>Figure 1: Horizontal, Left-to-Right
64 * </div>
65 * <div style="float:right">
66 * <p><img SRC="doc-files/GridLayout-2.gif"
67 * alt="Shows 6 buttons in rows of 2. Row 1 shows buttons 2 then 1.
68 * Row 2 shows buttons 4 then 3. Row 3 shows buttons 6 then 5.">
69 * <p>Figure 2: Horizontal, Right-to-Left
70 * </div>
71 * <br style="clear:both;">
72 * </div>
73 * <p>
74 * When both the number of rows and the number of columns have
75 * been set to non-zero values, either by a constructor or
76 * by the {@code setRows} and {@code setColumns} methods, the number of
77 * columns specified is ignored. Instead, the number of
78 * columns is determined from the specified number of rows
79 * and the total number of components in the layout. So, for
80 * example, if three rows and two columns have been specified
81 * and nine components are added to the layout, they will
82 * be displayed as three rows of three columns. Specifying
83 * the number of columns affects the layout only when the
84 * number of rows is set to zero.
85 *
86 * @author Arthur van Hoff
87 * @since 1.0
88 */
89 public class GridLayout implements LayoutManager, java.io.Serializable {
90 /*
91 * serialVersionUID
92 */
|