borderlayout.java
来自「gcc3.2.1源代码」· Java 代码 · 共 627 行 · 第 1/2 页
JAVA
627 行
/* BorderLayout.java -- A layout manager class Copyright (C) 1999, 2002 Free Software Foundation, Inc.This file is part of GNU Classpath.GNU Classpath is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2, or (at your option)any later version.GNU Classpath is distributed in the hope that it will be useful, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNUGeneral Public License for more details.You should have received a copy of the GNU General Public Licensealong with GNU Classpath; see the file COPYING. If not, write to theFree Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307 USA.Linking this library statically or dynamically with other modules ismaking a combined work based on this library. Thus, the terms andconditions of the GNU General Public License cover the wholecombination.As a special exception, the copyright holders of this library give youpermission to link this library with independent modules to produce anexecutable, regardless of the license terms of these independentmodules, and to copy and distribute the resulting executable underterms of your choice, provided that you also meet, for each linkedindependent module, the terms and conditions of the license of thatmodule. An independent module is a module which is not derived fromor based on this library. If you modify this library, you may extendthis exception to your version of the library, but you are notobligated to do so. If you do not wish to do so, delete thisexception statement from your version. */package java.awt;/** * This class implements a layout manager that positions components * in certain sectors of the parent container. * * @author Aaron M. Renn (arenn@urbanophile.com) * @author Rolf W. Rasmussen <rolfwr@ii.uib.no> */public class BorderLayout implements LayoutManager2, java.io.Serializable{/* * Static Variables *//** * Constant indicating the top of the container */public static final String NORTH = "North";/** * Constant indicating the bottom of the container */public static final String SOUTH = "South";/** * Constant indicating the right side of the container */public static final String EAST = "East";/** * Constant indicating the left side of the container */public static final String WEST = "West";/** * Constant indicating the center of the container */public static final String CENTER = "Center";/** * Constant indicating the position just after the last line of the * layout. */public static final String AFTER_LAST_LINE = "Last";/** * Constant indicating the position just after the end of the line. */public static final String AFTER_LINE_ENDS = "After";/** * Constant indicating the position just before the first line of the * layout. */public static final String BEFORE_FIRST_LINE = "First";/** * Constant indicating the position at the beginning of the line. */public static final String BEFORE_LINE_BEGINS = "Before";// Serialization constantprivate static final long serialVersionUID = -8658291919501921765L;/*************************************************************************//* * Instance Variables *//** * @serial */private Component north;/** * @serial */private Component south;/** * @serial */private Component east;/** * @serial */private Component west;/** * @serial */private Component center;/** * @serial */private Component firstLine;/** * @serial */private Component lastLine;/** * @serial */private Component firstItem;/** * @serial */private Component lastItem;/** * @serial The horizontal gap between components */private int hgap;/** * @serial The vertical gap between components */private int vgap;/*************************************************************************//* * Constructors *//** * Initializes a new instance of <code>BorderLayout</code> with no * horiztonal or vertical gaps between components. */publicBorderLayout(){ this(0,0);}/*************************************************************************//** * Initializes a new instance of <code>BorderLayout</code> with the * specified horiztonal and vertical gaps between components. * * @param hgap The horizontal gap between components. * @param vgap The vertical gap between components. */publicBorderLayout(int hgap, int vgap){ this.hgap = hgap; this.vgap = vgap;}/*************************************************************************//* * Instance Variables *//** * Returns the horitzontal gap value. * * @return The horitzontal gap value. */public intgetHgap(){ return(hgap);}/*************************************************************************//** * Sets the horizontal gap to the specified value. * * @param hgap The new horizontal gap. */public voidsetHgap(int hgap){ this.hgap = hgap;}/*************************************************************************//** * Returns the vertical gap value. * * @return The vertical gap value. */public intgetVgap(){ return(vgap);}/*************************************************************************//** * Sets the vertical gap to the specified value. * * @param vgap The new vertical gap value. */public voidsetVgap(int vgap){ this.vgap = vgap;}/*************************************************************************//** * Adds a component to the layout in the specified constraint position, * which must be one of the string constants defined in this class. * * @param component The component to add. * @param constraints The constraint string. * * @exception IllegalArgumentException If the constraint object is not * a string, or is not one of the specified constants in this class. */public voidaddLayoutComponent(Component component, Object constraints){ if (constraints != null && ! (constraints instanceof String)) throw new IllegalArgumentException("Constraint must be a string"); String str = (String)constraints; if (str == null || str.equals(CENTER)) center = component; else if (str.equals(NORTH)) north = component; else if (str.equals(SOUTH)) south = component; else if (str.equals(EAST)) east = component; else if (str.equals(WEST)) west = component; else if (str.equals(BEFORE_FIRST_LINE)) firstLine = component; else if (str.equals(AFTER_LAST_LINE)) lastLine = component; else if (str.equals(BEFORE_LINE_BEGINS)) firstItem = component; else if (str.equals(AFTER_LINE_ENDS)) lastItem = component; else throw new IllegalArgumentException("Constraint value not valid: " + str);}/*************************************************************************//** * Adds a component to the layout in the specified constraint position, * which must be one of the string constants defined in this class. * * @param constraints The constraint string. * @param component The component to add. * * @exception IllegalArgumentException If the constraint object is not * one of the specified constants in this class. * * @deprecated This method is deprecated in favor of * <code>addLayoutComponent(Component, Object)</code>. */public voidaddLayoutComponent(String constraints, Component component){ addLayoutComponent(component, constraints);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?