1 /* 2 * Copyright (c) 1997, 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 23 * questions. 24 */ 25 26 27 package javax.swing; 28 29 import java.awt.*; 30 import java.beans.ConstructorProperties; 31 import java.io.Serializable; 32 import java.io.PrintStream; 33 34 /** 35 * A layout manager that allows multiple components to be laid out either 36 * vertically or horizontally. The components will not wrap so, for 37 * example, a vertical arrangement of components will stay vertically 38 * arranged when the frame is resized. 39 * <table class="borderless" style="float:right"> 40 * <caption>Example:</caption> 41 * <TR> 42 * <TD style="text-align:center"> 43 * <P STYLE="TEXT-ALIGN:CENTER"><IMG SRC="doc-files/BoxLayout-1.gif" 44 * alt="The following text describes this graphic." 45 * WIDTH="191" HEIGHT="201" STYLE="FLOAT:BOTTOM; BORDER:0"> 46 * </TD> 47 * </TR> 48 * </TABLE> 49 * <p> 50 * Nesting multiple panels with different combinations of horizontal and 51 * vertical gives an effect similar to GridBagLayout, without the 52 * complexity. The diagram shows two panels arranged horizontally, each 53 * of which contains 3 components arranged vertically. 54 * 55 * <p> The BoxLayout manager is constructed with an axis parameter that 56 * specifies the type of layout that will be done. There are four choices: 57 * 58 * <blockquote><b>{@code X_AXIS}</b> - Components are laid out horizontally 59 * from left to right.</blockquote> 60 * 61 * <blockquote><b>{@code Y_AXIS}</b> - Components are laid out vertically 62 * from top to bottom.</blockquote> 63 * 64 * <blockquote><b>{@code LINE_AXIS}</b> - Components are laid out the way 65 * words are laid out in a line, based on the container's 66 * {@code ComponentOrientation} property. If the container's 67 * {@code ComponentOrientation} is horizontal then components are laid out 68 * horizontally, otherwise they are laid out vertically. For horizontal | 1 /* 2 * Copyright (c) 1997, 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 23 * questions. 24 */ 25 26 27 package javax.swing; 28 29 import java.awt.*; 30 import java.beans.ConstructorProperties; 31 import java.io.Serializable; 32 import java.io.PrintStream; 33 34 /** 35 * A layout manager that allows multiple components to be laid out either 36 * vertically or horizontally. The components will not wrap so, for 37 * example, a vertical arrangement of components will stay vertically 38 * arranged when the frame is resized. 39 * <div style="float:right;text-align:center;font-weight:bold"> 40 * <p>Example: 41 * <p><img src="doc-files/BoxLayout-1.gif" 42 * alt="The following text describes this graphic." 43 * width="191" height="201" style="float:bottom; border:0"> 44 * </div> 45 * <p> 46 * Nesting multiple panels with different combinations of horizontal and 47 * vertical gives an effect similar to GridBagLayout, without the 48 * complexity. The diagram shows two panels arranged horizontally, each 49 * of which contains 3 components arranged vertically. 50 * 51 * <p> The BoxLayout manager is constructed with an axis parameter that 52 * specifies the type of layout that will be done. There are four choices: 53 * 54 * <blockquote><b>{@code X_AXIS}</b> - Components are laid out horizontally 55 * from left to right.</blockquote> 56 * 57 * <blockquote><b>{@code Y_AXIS}</b> - Components are laid out vertically 58 * from top to bottom.</blockquote> 59 * 60 * <blockquote><b>{@code LINE_AXIS}</b> - Components are laid out the way 61 * words are laid out in a line, based on the container's 62 * {@code ComponentOrientation} property. If the container's 63 * {@code ComponentOrientation} is horizontal then components are laid out 64 * horizontally, otherwise they are laid out vertically. For horizontal |