/*
* @(#)Box.java 1.45 05/11/17
*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package javax.swing;
import java.awt.*;
import java.awt.event.*;
import java.beans.PropertyChangeListener;
import java.util.Locale;
import java.io.Serializable;
import javax.accessibility.*;
/**
* A lightweight container
* that uses a BoxLayout object as its layout manager.
* Box provides several class methods
* that are useful for containers using BoxLayout --
* even non-Box containers.
*
* <p>
* The <code>Box</code> class can create several kinds
* of invisible components
* that affect layout:
* glue, struts, and rigid areas.
* If all the components your <code>Box</code> contains
* have a fixed size,
* you might want to use a glue component
* (returned by <code>createGlue</code>)
* to control the components' positions.
* If you need a fixed amount of space between two components,
* try using a strut
* (<code>createHorizontalStrut</code> or <code>createVerticalStrut</code>).
* If you need an invisible component
* that always takes up the same amount of space,
* get it by invoking <code>createRigidArea</code>.
* <p>
* If you are implementing a <code>BoxLayout</code> you
* can find further information and examples in
* <a
href="http://java.sun.com/docs/books/tutorial/uiswing/layout/box.html">How to Use BoxLayout</a>,
* a section in <em>The Java Tutorial.</em>
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans<sup><font size="-2">TM</font></sup>
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @see BoxLayout
*
* @author Timothy Prinzing
* @version 1.45 11/17/05
*/
public class Box extends JComponent implements Accessible {
/**
* Creates a <code>Box</code> that displays its components
* along the the specified axis.
*
* @param axis can be {@link BoxLayout#X_AXIS},
* {@link BoxLayout#Y_AXIS},
* {@link BoxLayout#LINE_AXIS} or
* {@link BoxLayout#PAGE_AXIS}.
* @throws AWTError if the <code>axis</code> is invalid
* @see #createHorizontalBox
* @see #createVerticalBox
*/
public Box(int axis) {
super();
super.setLayout(new BoxLayout(this, axis));
}
/**
* Creates a <code>Box</code> that displays its components
* from left to right. If you want a <code>Box</code> that
* respects the component orientation you should create the
* <code>Box</code> using the constructor and pass in
* <code>BoxLayout.LINE_AXIS</code>, eg:
* <pre>
* Box lineBox = new Box(BoxLayout.LINE_AXIS);
* </pre>
*
* @return the box
*/
public static Box createHorizontalBox() {
return new Box(BoxLayout.X_AXIS);
}
/**
* Creates a <code>Box</code> that displays its components
* from top to bottom. If you want a <code>Box</code> that
* respects the component orientation you should create the
=1= |