|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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 FormField Summary | |
(package private) int |
currentCard
|
(package private) int |
hgap
|
private static ObjectStreamField[] |
serialPersistentFields
|
private static long |
serialVersionUID
|
(package private) Vector |
vector
|
(package private) int |
vgap
|
Constructor Summary | |
CardLayout()
Enabled: Creates a new card layout with gaps of size zero. |
|
CardLayout(int hgap,
int vgap)
Enabled: Creates a new card layout with the specified horizontal and vertical gaps. |
Method Summary | |
void |
addLayoutComponent(Component comp,
Object constraints)
Enabled: Adds the specified component to this card layout's internal table of names. |
void |
addLayoutComponent(String name,
Component comp)
Enabled: @deprecated replaced by addLayoutComponent(Component, Object) . |
(package private) void |
checkLayout(Container parent)
Make sure that the Container really has a CardLayout installed. |
void |
first(Container parent)
Enabled: Flips to the first card of the container. |
int |
getHgap()
Enabled: Gets the horizontal gap between components. |
float |
getLayoutAlignmentX(Container parent)
Enabled: Returns the alignment along the x axis. |
float |
getLayoutAlignmentY(Container parent)
Enabled: Returns the alignment along the y axis. |
int |
getVgap()
Enabled: Gets the vertical gap between components. |
void |
invalidateLayout(Container target)
Enabled: Invalidates the layout, indicating that if the layout manager has cached information it should be discarded. |
void |
last(Container parent)
Enabled: Flips to the last card of the container. |
void |
layoutContainer(Container parent)
Enabled: Lays out the specified container using this card layout. |
Dimension |
maximumLayoutSize(Container target)
Enabled: Returns the maximum dimensions for this layout given the components in the specified target container. |
Dimension |
minimumLayoutSize(Container parent)
Enabled: Calculates the minimum size for the specified panel. |
void |
next(Container parent)
Enabled: Flips to the next card of the specified container. |
Dimension |
preferredLayoutSize(Container parent)
Enabled: Determines the preferred size of the container argument using this card layout. |
void |
previous(Container parent)
Enabled: Flips to the previous card of the specified container. |
private void |
readObject(ObjectInputStream s)
Reads serializable fields from stream. |
void |
removeLayoutComponent(Component comp)
Enabled: Removes the specified component from the layout. |
void |
setHgap(int hgap)
Enabled: Sets the horizontal gap between components. |
void |
setVgap(int vgap)
Enabled: Sets the vertical gap between components. |
(package private) void |
show(Container parent,
int newIndex)
|
void |
show(Container parent,
String name)
Enabled: Flips to the component that was added to this layout with the specified name , using addLayoutComponent . |
String |
toString()
Suppressed: Returns a string representation of the state of this card layout. |
private void |
writeObject(ObjectOutputStream s)
Writes serializable fields to stream. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private static final long serialVersionUID
Vector vector
int currentCard
int hgap
int vgap
private static final ObjectStreamField[] serialPersistentFields
Constructor Detail |
public CardLayout()
public CardLayout(int hgap, int vgap)
hgap
- the horizontal gap.vgap
- the vertical gap.Method Detail |
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 LayoutManager2
comp
- 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 LayoutManager
name
- the string to be associated with the componentcomp
- the component to be addedpublic void removeLayoutComponent(Component comp)
removeLayoutComponent
in interface LayoutManager
comp
- the component to be removed.java.awt.Container#remove(java.awt.Component)
,
java.awt.Container#removeAll()
public Dimension preferredLayoutSize(Container parent)
preferredLayoutSize
in interface LayoutManager
parent
- the name of the parent container.
java.awt.Container#getPreferredSize
,
java.awt.CardLayout#minimumLayoutSize
public Dimension minimumLayoutSize(Container parent)
minimumLayoutSize
in interface LayoutManager
parent
- the name of the parent container
in which to do the layout.
java.awt.Container#doLayout
,
java.awt.CardLayout#preferredLayoutSize
public Dimension maximumLayoutSize(Container target)
maximumLayoutSize
in interface LayoutManager2
target
- the component which needs to be laid outContainer
,
minimumLayoutSize(java.awt.Container)
,
preferredLayoutSize(java.awt.Container)
public float getLayoutAlignmentX(Container parent)
getLayoutAlignmentX
in interface LayoutManager2
public float getLayoutAlignmentY(Container parent)
getLayoutAlignmentY
in interface LayoutManager2
public void invalidateLayout(Container target)
invalidateLayout
in interface LayoutManager2
public 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 LayoutManager
parent
- the name of the parent container
in which to do the layout.java.awt.Container#doLayout
void checkLayout(Container parent)
public void first(Container parent)
parent
- the name of the parent container
in which to do the layout.java.awt.CardLayout#last
public void next(Container parent)
parent
- the name of the parent container
in which to do the layout.java.awt.CardLayout#previous
public void previous(Container parent)
parent
- the name of the parent container
in which to do the layout.java.awt.CardLayout#next
public void last(Container parent)
parent
- the name of the parent container
in which to do the layout.java.awt.CardLayout#first
public 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()
toString
in class Object
private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException
ClassNotFoundException
IOException
private void writeObject(ObjectOutputStream s) throws IOException
IOException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |