java.lang.Object | +--java.awt.CardLayout
Safe: 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(java.awt.Component, java.lang.Object)
method can be used to associate a string identifier with a given card
for fast random access.
java.awt.Container,
Serialized FormCardLayout()
CardLayout(int hgap,
int vgap)
void
addLayoutComponent(Component comp,
Object constraints)
void
addLayoutComponent(String name,
Component comp)
addLayoutComponent(Component, Object).
(package private) void
checkLayout(Container parent)
void
invalidateLayout(Container target)
void
layoutContainer(Container parent)
Dimension
maximumLayoutSize(Container target)
Dimension
minimumLayoutSize(Container parent)
Dimension
preferredLayoutSize(Container parent)
void
removeLayoutComponent(Component comp)
void
show(Container parent,
String name)
name, using addLayoutComponent.
private static final long serialVersionUID
Vector vector
int currentCard
int hgap
int vgap
private static final ObjectStreamField[] serialPersistentFields
public CardLayout()
public CardLayout(int hgap, int vgap)
hgap - the horizontal gap.vgap - the vertical gap.public int getHgap()
java.awt.CardLayout#setHgap(int),
java.awt.CardLayout#getVgap()public void setHgap(int hgap)
hgap - the horizontal gap between components.java.awt.CardLayout#getHgap(),
java.awt.CardLayout#setVgap(int)public int getVgap()
java.awt.CardLayout#setVgap(int),
java.awt.CardLayout#getHgap()public void setVgap(int vgap)
vgap - the vertical gap between components.java.awt.CardLayout#getVgap(),
java.awt.CardLayout#setHgap(int)public void addLayoutComponent(Component comp, Object constraints)
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.
addLayoutComponent in interface LayoutManager2comp - the component to be added.constraints - a tag that identifies a particular
card in the layout.java.awt.CardLayout#show(java.awt.Container, java.lang.String)public void addLayoutComponent(String name, Component comp)
addLayoutComponent(Component, Object).
addLayoutComponent in interface LayoutManagername - the string to be associated with the componentcomp - the component to be addedpublic void removeLayoutComponent(Component comp)
removeLayoutComponent in interface LayoutManagercomp - the component to be removed.java.awt.Container#remove(java.awt.Component),
java.awt.Container#removeAll()public Dimension preferredLayoutSize(Container parent)
preferredLayoutSize in interface LayoutManagerparent - the name of the parent container.
java.awt.Container#getPreferredSize,
java.awt.CardLayout#minimumLayoutSizepublic Dimension minimumLayoutSize(Container parent)
minimumLayoutSize in interface LayoutManagerparent - the name of the parent container
in which to do the layout.
java.awt.Container#doLayout,
java.awt.CardLayout#preferredLayoutSizepublic Dimension maximumLayoutSize(Container target)
maximumLayoutSize in interface LayoutManager2target - the component which needs to be laid outContainer,
minimumLayoutSize(java.awt.Container),
preferredLayoutSize(java.awt.Container)public float getLayoutAlignmentX(Container parent)
getLayoutAlignmentX in interface LayoutManager2public float getLayoutAlignmentY(Container parent)
getLayoutAlignmentY in interface LayoutManager2public void invalidateLayout(Container target)
invalidateLayout in interface LayoutManager2public void layoutContainer(Container parent)
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.
layoutContainer in interface LayoutManagerparent - the name of the parent container
in which to do the layout.java.awt.Container#doLayoutvoid checkLayout(Container parent)
public void first(Container parent)
parent - the name of the parent container
in which to do the layout.java.awt.CardLayout#lastpublic void next(Container parent)
parent - the name of the parent container
in which to do the layout.java.awt.CardLayout#previouspublic void previous(Container parent)
parent - the name of the parent container
in which to do the layout.java.awt.CardLayout#nextpublic void last(Container parent)
parent - the name of the parent container
in which to do the layout.java.awt.CardLayout#firstpublic void show(Container parent, String name)
name, using addLayoutComponent.
If no such component exists, then nothing happens.
parent - the name of the parent container
in which to do the layout.name - the component name.java.awt.CardLayout#addLayoutComponent(java.awt.Component, java.lang.Object)void show(Container parent, int newIndex)
public String toString()
private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException
private void writeObject(ObjectOutputStream s) throws IOException