All Packages Class Hierarchy This Package Previous Next Index
Class java.awt.swing.Box
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Container
|
+----java.awt.swing.Box
- public class Box
- extends Container
- implements Accessible
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.
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
.
- See Also:
- BoxLayout
Box.Filler- An implementation of a lightweight component that participates in
layout but has no view.
accessibleDescription-
accessibleName-
Box(int)
- Creates a
Box
that displays its components
along the the specified axis.
addAccessibleSelection(int)
- Adds the nth selected item in the object to the object's
selection.
clearAccessibleSelection()
- Clears the selection in the object, so that nothing in the
object is selected.
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).
createHorizontalBox()
- Creates a
Box
that displays its components
from left to right.
createHorizontalGlue()
-
createHorizontalStrut(int)
- Creates an invisible, fixed-width component.
createRigidArea(Dimension)
- Creates an invisible component that's always the specified size.
createVerticalBox()
- Creates a
Box
that displays its components
from top to bottom.
createVerticalGlue()
-
createVerticalStrut(int)
- Creates an invisible, fixed-height component.
doAccessibleAction(int)
- Perform the nth Action on the object
getAccessibleActionCount()
- Returns the number of Actions available in this object
If there is more than one, the first one is the "default"
action (if any action is considered "default").
getAccessibleActionDescription(int)
- Return a description of the nth action of the object.
getAccessibleAt(Point)
- Returns the Accessible child contained at the local coordinate
Point, if one exists.
getAccessibleChild(int)
- Return the nth Accessible child of the object.
getAccessibleChildrenCount()
- Returns the number of accessible children in the object.
getAccessibleDescription()
- Get the accessible description of this object.
getAccessibleName()
- Get the accessible name of this object.
getAccessibleParent()
- Get the Accessible parent of this object.
getAccessibleRole()
- Get the role of this object.
getAccessibleSelection(int)
- Returns an Accessible representing the nth selected item
in the object.
getAccessibleSelectionCount()
- Returns the number of items currently selected.
getAccessibleStateSet()
- Get the state of this object.
getAccessibleText()
- Gets the AccessibleText interface for the component.
getAccessibleValue()
- Get the value of this object as a Number.
getMaximumAccessibleValue()
- Get the maximum value of this object as a Number.
getMinimumAccessibleValue()
- Get the minimum value of this object as a Number.
getNextAccessibleSibling()
- Get the next sibling of this Accessible, if a preferred one exists.
getPreviousAccessibleSibling()
- Get the previous sibling of this Accessible, if a preferred one exists.
removeAccessibleSelection(int)
- Removes the nth selected item in the object from the object's
selection.
selectAllAccessibleSelection()
- Causes every selected item in the object to be selected,
if the object supports multiple selections (if getAccessibleStateSet
returns a state that is MULTISELECTABLE).
setAccessibleDescription(String)
- Set the accessible description of this object.
setAccessibleName(String)
- Set the localized accessible name of this object.
setAccessibleValue(Number)
- Get the value of this object as a Number.
setLayout(LayoutManager)
- Throws an AWTError, since a Box can use only a BoxLayout.
accessibleName
protected String accessibleName
accessibleDescription
protected String accessibleDescription
Box
public Box(int axis)
- Creates a
Box
that displays its components
along the the specified axis.
- Parameters:
- axis - can be either
BoxLayout.X_AXIS
(to display components from left to right) or
BoxLayout.Y_AXIS
(to display them from top to bottom)
- See Also:
- createHorizontalBox, createVerticalBox
createHorizontalBox
public static Box createHorizontalBox()
- Creates a
Box
that displays its components
from left to right.
createVerticalBox
public static Box createVerticalBox()
- Creates a
Box
that displays its components
from top to bottom.
createRigidArea
public static Component createRigidArea(Dimension d)
- Creates an invisible component that's always the specified size.
- Parameters:
- d - the dimensions of the invisible component
- See Also:
- createGlue, createHorizontalStrut, createVerticalStrut
createHorizontalStrut
public static Component createHorizontalStrut(int width)
- Creates an invisible, fixed-width component.
In a horizontal box,
you typically use this method
to force a certain amount of space between two components.
In a vertical box,
you might use this method
to force the box to be at least the specified width.
The invisible component has no height
unless excess space is available,
in which case it takes its share of available space,
just like any other component that has no maximum height.
- Parameters:
- width - the width of the invisible component, in pixels
- See Also:
- createVerticalStrut, createGlue, createRigidArea
createVerticalStrut
public static Component createVerticalStrut(int height)
- Creates an invisible, fixed-height component.
In a vertical box,
you typically use this method
to force a certain amount of space between two components.
In a horizontal box,
you might use this method
to force the box to be at least the specified height.
The invisible component has no width
unless excess space is available,
in which case it takes its share of available space,
just like any other component that has no maximum width.
- Parameters:
- height - the height of the invisible component, in pixels
- See Also:
- createHorizontalStrut, createGlue, createRigidArea
createGlue
public 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).
You can think of the glue component
as being a gooey substance
that expands as much as necessary
to fill the space between its neighboring components.
For example, suppose you have
a horizontal box that contains two fixed-size components.
If the box gets extra space,
the fixed-size components won't become larger,
so where does the extra space go?
Without glue,
the extra space goes to the right of the second component.
If you put glue between the fixed-size components,
then the extra space goes there.
If you put glue before the first fixed-size component,
the extra space goes there,
and the fixed-size components are shoved against the right
edge of the box.
If you put glue before the first fixed-size component
and after the second fixed-size component,
the fixed-size components are centered in the box.
To use glue,
call Box.createGlue
and add the returned component to a container.
The glue component has no minimum or preferred size,
so it takes no space unless excess space is available.
If excess space is available,
then the glue component takes its share of available
horizontal or vertical space,
just like any other component that has no maximum width or height.
createHorizontalGlue
public static Component createHorizontalGlue()
createVerticalGlue
public static Component createVerticalGlue()
setLayout
public void setLayout(LayoutManager l)
- Throws an AWTError, since a Box can use only a BoxLayout.
- Overrides:
- setLayout in class Container
getNextAccessibleSibling
public Accessible getNextAccessibleSibling()
- Get the next sibling of this Accessible, if a preferred one exists.
This should generally return the next item in the tab order, if
that item implements Accessible
- Returns:
- the next Accessible, if there is one
getPreviousAccessibleSibling
public Accessible getPreviousAccessibleSibling()
- Get the previous sibling of this Accessible, if a preferred one exists.
This should generally return the previous item in the tab order, if
that item implements Accessible
- Returns:
- the previous Accessible, if there is one
getAccessibleAt
public Accessible getAccessibleAt(Point p)
- Returns the Accessible child contained at the local coordinate
Point, if one exists.
- Returns:
- the Accessible at the specified location, if it exists
getAccessibleName
public String getAccessibleName()
- Get the accessible name of this object. This should almost never
return java.awt.Component.getName(), as that generally isn't
a localized name, and doesn't have meaning for the user. If the
object is fundamentally a text object (e.g. a menu item), the
accessible name should be the text of the object (e.g. "save").
If the object has a tooltip, the tooltip text may also be an
appropriate String to return.
- Returns:
- the localized name of the object -- can be null if this
object does not have a name
- See Also:
- setAccessibleName
setAccessibleName
public void setAccessibleName(String s)
- Set the localized accessible name of this object.
- Parameters:
- s - the new localized name of the object.
- See Also:
- getAccessibleName
getAccessibleDescription
public String getAccessibleDescription()
- Get the accessible description of this object. This should be
a concise, localized description of what this object is - what
is it's meaning to the user. If the object has a tooltip, the
tooltip text may be an appropriate string to return, assuming
it contains a concise description of the object (instead of just
the name of the object - e.g. a "Save" icon on a toolbar that
had "save" as the tooltip text shouldn't return the tooltip
text as the description, but something like "Saves the current
text document" instead).
- Returns:
- the localized description of the object -- can be null if
this object does not have a description
- See Also:
- setAccessibleDescription
setAccessibleDescription
public void setAccessibleDescription(String s)
- Set the accessible description of this object.
- Parameters:
- s - the new localized description of the object
- See Also:
- getAccessibleDescription
getAccessibleStateSet
public AccessibleStateSet getAccessibleStateSet()
- Get the state of this object.
- Returns:
- an instance of AccessibleStateSet containing the current state
set of the object
- See Also:
- AccessibleState
getAccessibleRole
public AccessibleRole getAccessibleRole()
- Get the role of this object.
- Returns:
- an instance of AccessibleRole describing the role of the object
- See Also:
- AccessibleRole
getAccessibleValue
public Number getAccessibleValue()
- Get the value of this object as a Number.
- Returns:
- value of the object -- can be null if this object does not
have a value
setAccessibleValue
public boolean setAccessibleValue(Number n)
- Get the value of this object as a Number.
- Returns:
- value of the object -- can be null if this object does not
have a value
getMinimumAccessibleValue
public Number getMinimumAccessibleValue()
- Get the minimum value of this object as a Number.
- Returns:
- Minimum value of the object; null if this object does not
have a minimum value
getMaximumAccessibleValue
public Number getMaximumAccessibleValue()
- Get the maximum value of this object as a Number.
- Returns:
- Maximum value of the object; null if this object does not
have a maximum value
getAccessibleParent
public Accessible getAccessibleParent()
- Get the Accessible parent of this object. If the parent of this
object implements Accessible, this method should simply return
getParent().
- Returns:
- the Accessible parent of this object -- can be null if this
object does not have an Accessible parent
getAccessibleChildrenCount
public int getAccessibleChildrenCount()
- Returns the number of accessible children in the object. If all
of the children of this object implement Accessible, than this
method should return the number of children of this object.
- Returns:
- the number of accessible children in the object.
getAccessibleChild
public Accessible getAccessibleChild(int i)
- Return the nth Accessible child of the object.
- Parameters:
- i - zero-based index of child
- Returns:
- the nth Accessible child of the object
getAccessibleActionCount
public int getAccessibleActionCount()
- Returns the number of Actions available in this object
If there is more than one, the first one is the "default"
action (if any action is considered "default").
- Returns:
- the number of Actions in this object
getAccessibleActionDescription
public String getAccessibleActionDescription(int i)
- Return a description of the nth action of the object.
This description should be human-readable; by default
it currently isn't...
- Parameters:
- i - zero-based index of the actions
- Returns:
- a description of the nth action
doAccessibleAction
public boolean doAccessibleAction(int i)
- Perform the nth Action on the object
- Parameters:
- i - zero-based index of actions
- Returns:
- whether the action was performed or not.
getAccessibleText
public AccessibleText getAccessibleText()
- Gets the AccessibleText interface for the component. If the component
does not speak AccessibleText, or have a proxy which does, this
method returns null.
- Returns:
- the AccessibleText of the object.
- See Also:
- AccessibleText
getAccessibleSelectionCount
public int getAccessibleSelectionCount()
- Returns the number of items currently selected.
If no items are selected, the return value will be 0.
- Returns:
- the number of items currently selected.
getAccessibleSelection
public Accessible getAccessibleSelection(int i)
- Returns an Accessible representing the nth selected item
in the object. If there isn't a selection, or there are
fewer items selcted than the integer passed in, the return
value will be null.
- Parameters:
- i - the zero-based index of selected items
- Returns:
- an Accessible containing the selected item
addAccessibleSelection
public void addAccessibleSelection(int i)
- Adds the nth selected item in the object to the object's
selection. If the object supports multiple selections,
(the method getAccessibleStateSet returns a state that is MULTISELECTABLE)
the nth item is added to any existing selection, otherwse
it replaces any existing selection in the objct. If the
nth item is already selected, this method has no effect.
- Parameters:
- i - the zero-based index of selectable items
- See Also:
- getAccessibleStateSet
removeAccessibleSelection
public void removeAccessibleSelection(int i)
- Removes the nth selected item in the object from the object's
selection. If the nth item isn't currently selected, this
method has no effect.
- Parameters:
- i - the zero-based index of selectable items
clearAccessibleSelection
public void clearAccessibleSelection()
- Clears the selection in the object, so that nothing in the
object is selected.
selectAllAccessibleSelection
public void selectAllAccessibleSelection()
- Causes every selected item in the object to be selected,
if the object supports multiple selections (if getAccessibleStateSet
returns a state that is MULTISELECTABLE).
- See Also:
- getAccessibleStateSet
All Packages Class Hierarchy This Package Previous Next Index
Submit a bug or feature