These are used for spacingĤ9: * author Tom Tromey * author Aaron M. This classĤ6: * supports horizontal and vertical gaps. When a component cannot be placedĤ5: * without horizontal clipping, a new row is started. Components are laidĤ4: * out in order from left to right. */ 37: 38: 39: package java.awt Ĥ2: 43: /** This class implements a flow-based layout. If you do not wish to do so, delete thisģ6:exception statement from your version. If you modify this library, you may extendģ4:this exception to your version of the library, but you are notģ5: obligated to do so. An independent module is a module which is not derived fromģ3:or based on this library. Thus, the terms andĢ3:conditions of the GNU General Public License cover the wholeĢ5: 26:As a special exception, the copyright holders of this library give youĢ7:permission to link this library with independent modules to produce anĢ8:executable, regardless of the license terms of these independentĢ9:modules, and to copy and distribute the resulting executable underģ0: terms of your choice, provided that you also meet, for each linkedģ1:independent module, the terms and conditions of the license of thatģ2:module. If not, write to theġ8:Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MAĢ0: 21:Linking this library statically or dynamically with other modules isĢ2:making a combined work based on this library. See the GNUġ4:General Public License for more details.ġ5: 16:You should have received a copy of the GNU General Public Licenseġ7:along with GNU Classpath see the file COPYING. The following property will be in effect for both the scenarios. The core function of FlowLayout is to layout the child controls either horizontally or vertically. 1: /* FlowLayout.java - Grid-based layout engineĢ: Copyright (C) 1999, 2000, 2001, 2002, 2004 Free Software Foundationĥ: 6:GNU Classpath is free software you can redistribute it and/or modifyħ:it under the terms of the GNU General Public License as published byĨ:the Free Software Foundation either version 2, or (at your option)ġ0: 11:GNU Classpath is distributed in the hope that it will be useful, butġ2:WITHOUT ANY WARRANTY without even the implied warranty ofġ3:MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 3, FlowLayout(int align, int hgap, int vgap) Creates a new flow layout manager with the indicated alignment and the indicated horizontal and vertical gaps. Configuring FlowLayout in Windows Forms LayoutManagers. creating and showing this application's GUI. The horizontalGap and verticalGap arguments specify the number of pixels to put between components. Schedule a job for the event-dispatching thread: When the FlowLayout controls a container with a left-to-right component orientation (the default), LEADING specifies that the components be left-aligned and TRAILING specifies right alignment. tVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS) įrame.getContentPane().add(scrollableTextArea) tHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS) JScrollPane scrollableTextArea = new JScrollPane(textArea) Read the Swing tutorial on Layout Managers for more information and examples. Each child panel can contain a panel using a FlowLayout with two components. JTextArea textArea = new JTextArea(5, 5) Then you create child panels to add to the layout. Private static final long serialVersionUID = 1L įinal JFrame frame = new JFrame("Scroll Pane Example") įtDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) įrame.getContentPane().setLayout(new FlowLayout()) Use setHorizontalScrollBarPolicy and setVerticalScrollBarPolicy to set the vertical and horizontal scroll bar policies.value: hgap - the horizontal gap variable: vgap - the vertical gap variable. Remember that JScrollPane is a container and you can add any component you want to it to make it scrollable. FlowLayout(): Constructs a new Flow Layout with a centered alignment. For each newly added control, the layout grows vertically. Say, for example, we have a box layout to lay out controls vertically. Unlike FlowLayout, this Layout grows in a distinct direction. Call new JScrollPane(textArea) to create a scrollable Text Area. This layout will help in forming the controls either vertically or horizontally. It is very simple to create a JScrollPane.
0 Comments
Leave a Reply. |