public class Box extends JComponent implements Accessible
The Box
class can create several kinds
of invisible components
that affect layout:
glue, struts, and rigid areas.
If all the components your Box
contains
have a fixed size,
you might want to use a glue component
(returned by createGlue
)
to control the components' positions.
If you need a fixed amount of space between two components,
try using a strut
(createHorizontalStrut
or createVerticalStrut
).
If you need an invisible component
that always takes up the same amount of space,
get it by invoking createRigidArea
.
If you are implementing a BoxLayout
you
can find further information and examples in
How to Use BoxLayout,
a section in The Java Tutorial.
Warning:
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 JavaBeansTM
has been added to the java.beans
package.
Please see XMLEncoder
.
BoxLayout
Modifier and Type | Class and Description |
---|---|
protected class |
Box.AccessibleBox
This class implements accessibility support for the
Box class. |
static class |
Box.Filler
An implementation of a lightweight component that participates in
layout but has no view.
|
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
Box(int axis)
Creates a
Box that displays its components
along the the specified axis. |
Modifier and Type | Method and Description |
---|---|
static Component |
createGlue()
Creates an invisible "glue" component
that can be useful in a Box
whose visible components have a maximum width
(for a horizontal box)
or height (for a vertical box).
|
static Box |
createHorizontalBox()
Creates a
Box that displays its components
from left to right. |
static Component |
createHorizontalGlue()
Creates a horizontal glue component.
|
static Component |
createHorizontalStrut(int width)
Creates an invisible, fixed-width component.
|
static Component |
createRigidArea(Dimension d)
Creates an invisible component that's always the specified size.
|
static Box |
createVerticalBox()
Creates a
Box that displays its components
from top to bottom. |
static Component |
createVerticalGlue()
Creates a vertical glue component.
|
static Component |
createVerticalStrut(int height)
Creates an invisible, fixed-height component.
|
AccessibleContext |
getAccessibleContext()
Gets the AccessibleContext associated with this Box.
|
protected void |
paintComponent(Graphics g)
Paints this
Box . |
void |
setLayout(LayoutManager l)
Throws an AWTError, since a Box can use only a BoxLayout.
|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty,