java.lang.Object | |
↳ | java.awt.CardLayout |
A CardLayout
object is a layout manager for a
container. It treats each component in the container as a card.
Only one card is visible at a time, and the container acts as
a stack of cards. The first component added to a
CardLayout
object is the visible component when the
container is first displayed.
The ordering of cards is determined by the container's own internal
ordering of its component objects. CardLayout
defines a set of methods that allow an application to flip
through these cards sequentially, or to show a specified card.
The addLayoutComponent(Component, Object)
method can be used to associate a string identifier with a given card
for fast random access.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates a new card layout with gaps of size zero.
| |||||||||||
Creates a new card layout with the specified horizontal and
vertical gaps.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
This method is deprecated.
replaced by
addLayoutComponent(Component, Object) .
| |||||||||||
Adds the specified component to this card layout's internal
table of names.
| |||||||||||
Flips to the first card of the container.
| |||||||||||
Gets the horizontal gap between components.
| |||||||||||
Returns the alignment along the x axis.
| |||||||||||
Returns the alignment along the y axis.
| |||||||||||
Gets the vertical gap between components.
| |||||||||||
Invalidates the layout, indicating that if the layout manager
has cached information it should be discarded.
| |||||||||||
Flips to the last card of the container.
| |||||||||||
Lays out the specified container using this card layout.
| |||||||||||
Returns the maximum dimensions for this layout given the components
in the specified target container.
| |||||||||||
Calculates the minimum size for the specified panel.
| |||||||||||
Flips to the next card of the specified container.
| |||||||||||
Determines the preferred size of the container argument using
this card layout.
| |||||||||||
Flips to the previous card of the specified container.
| |||||||||||
Removes the specified component from the layout.
| |||||||||||
Sets the horizontal gap between components.
| |||||||||||
Sets the vertical gap between components.
| |||||||||||
Flips to the component that was added to this layout with the
specified
name , using addLayoutComponent . | |||||||||||
Returns a string representation of the state of this card layout.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() | |||||||||||
![]() |
Creates a new card layout with gaps of size zero.
Creates a new card layout with the specified horizontal and vertical gaps. The horizontal gaps are placed at the left and right edges. The vertical gaps are placed at the top and bottom edges.
hgap | the horizontal gap. |
---|---|
vgap | the vertical gap. |
This method is deprecated.
replaced by
addLayoutComponent(Component, Object)
.
If the layout manager uses a per-component string,
adds the component comp
to the layout,
associating it
with the string specified by name
.
name | the string to be associated with the component |
---|---|
comp | the component to be added |
Adds the specified component to this card layout's internal
table of names. The object specified by constraints
must be a string. The card layout stores this string as a key-value
pair that can be used for random access to a particular card.
By calling the show
method, an application can
display the component with the specified name.
comp | the component to be added. |
---|---|
constraints | a tag that identifies a particular card in the layout. |
IllegalArgumentException | if the constraint is not a string. |
---|
Flips to the first card of the container.
parent | the parent container in which to do the layout |
---|
Gets the horizontal gap between components.
Returns the alignment along the x axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.
Returns the alignment along the y axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.
Gets the vertical gap between components.
Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.
Flips to the last card of the container.
parent | the parent container in which to do the layout |
---|
Lays out the specified container using this card layout.
Each component in the parent
container is reshaped
to be the size of the container, minus space for surrounding
insets, horizontal gaps, and vertical gaps.
parent | the parent container in which to do the layout |
---|
Returns the maximum dimensions for this layout given the components in the specified target container.
target | the component which needs to be laid out |
---|
Calculates the minimum size for the specified panel.
parent | the parent container in which to do the layout |
---|
Flips to the next card of the specified container. If the currently visible card is the last one, this method flips to the first card in the layout.
parent | the parent container in which to do the layout |
---|
Determines the preferred size of the container argument using this card layout.
parent | the parent container in which to do the layout |
---|
Flips to the previous card of the specified container. If the currently visible card is the first one, this method flips to the last card in the layout.
parent | the parent container in which to do the layout |
---|
Removes the specified component from the layout. If the card was visible on top, the next card underneath it is shown.
comp | the component to be removed. |
---|
Sets the horizontal gap between components.
hgap | the horizontal gap between components. |
---|
Sets the vertical gap between components.
vgap | the vertical gap between components. |
---|
Flips to the component that was added to this layout with the
specified name
, using addLayoutComponent
.
If no such component exists, then nothing happens.
parent | the parent container in which to do the layout |
---|---|
name | the component name |
Returns a string representation of the state of this card layout.