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 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
method can be used to associate a string identifier with a given card
for fast random access.
Returns a string representation of the state of this card layout.
CardLayout
public CardLayout()
Creates a new card layout with gaps of size zero.
CardLayout
public CardLayout(int hgap,
int vgap)
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.
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.
Parameters:
comp - the component to be added.
constraints - a tag that identifies a particular
card in the layout.
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.
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.
Parameters:
parent - the name of 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.
Parameters:
parent - the name of the parent container
in which to do the layout.
Flips to the component that was added to this layout with the
specified name, using addLayoutComponent.
If no such component exists, then nothing happens.
Parameters:
parent - the name of the parent container
in which to do the layout.