| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
CardLayout cardLayout = new CardLayout();
Based on 95 examples
public class CardLayout extends Object implements LayoutManager2, Serializable
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 {@link CardLayout#addLayoutComponent}
method can be used to associate a string identifier with a given card
for fast random access.
Constructor Summary | |
---|---|
Creates a new card layout with gaps of size zero. |
|
CardLayout(int hgap, int vgap) Creates a new card layout with the specified horizontal and vertical gaps. |
Method Summary | |
---|---|
void |
addLayoutComponent(Component comp, Object constraints) Adds the specified component to this card layout's internal table of names. |
void |
addLayoutComponent(String name, Component comp) |
void |
Flips to the first card of the container. |
int |
getHgap() Gets the horizontal gap between components. |
float |
getLayoutAlignmentX(Container parent) Returns the alignment along the x axis. |
float |
getLayoutAlignmentY(Container parent) Returns the alignment along the y axis. |
int |
getVgap() Gets the vertical gap between components. |
void |
invalidateLayout(Container target) Invalidates the layout, indicating that if the layout manager has cached information it should be discarded. |
void |
Flips to the last card of the container. |
void |
layoutContainer(Container parent) Lays out the specified container using this card layout. |
Dimension |
maximumLayoutSize(Container target) Returns the maximum dimensions for this layout given the components in the specified target container. |
Dimension |
minimumLayoutSize(Container parent) Calculates the minimum size for the specified panel. |
void |
Flips to the next card of the specified container. |
Dimension |
preferredLayoutSize(Container parent) Determines the preferred size of the container argument using this card layout. |
void |
Flips to the previous card of the specified container. |
void |
Removes the specified component from the layout. |
void |
setHgap(int hgap) Sets the horizontal gap between components. |
void |
setVgap(int vgap) Sets the vertical gap between components. |
void |
Flips to the component that was added to this layout with the specified name , using addLayoutComponent .
|
String |
toString() Returns a string representation of the state of this card layout. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CardLayout()
public CardLayout(int hgap, int vgap)
hgap
- the horizontal gap.vgap
- the vertical gap.Method Detail |
---|
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.
comp
- the component to be added.constraints
- a tag that identifies a particular
card in the layout.public void addLayoutComponent(String name, Component comp)
name
comp
public void first(Container parent)
parent
- the parent container in which to do the layoutpublic int getHgap()
public float getLayoutAlignmentX(Container parent)
parent
public float getLayoutAlignmentY(Container parent)
parent
public int getVgap()
public void invalidateLayout(Container target)
target
public void last(Container parent)
parent
- the parent container in which to do the layoutpublic 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.
parent
- the parent container in which to do the layoutpublic Dimension maximumLayoutSize(Container target)
target
- the component which needs to be laid outpublic Dimension minimumLayoutSize(Container parent)
parent
- the parent container in which to do the layoutpublic void next(Container parent)
parent
- the parent container in which to do the layoutpublic Dimension preferredLayoutSize(Container parent)
parent
- the parent container in which to do the layoutpublic void previous(Container parent)
parent
- the parent container in which to do the layoutpublic void removeLayoutComponent(Component comp)
comp
- the component to be removed.public void setHgap(int hgap)
hgap
- the horizontal gap between components.public void setVgap(int vgap)
vgap
- the vertical gap between components.public void show(Container parent, String name)
name
, using addLayoutComponent
.
If no such component exists, then nothing happens.
parent
- the parent container in which to do the layoutname
- the component namepublic String toString()
toString
in class Object
| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |