Class java.awt.CardLayout
All Packages Class Hierarchy This Package Previous Next Index
Class java.awt.CardLayout
Object
|
+----java.awt.CardLayout
- 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 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.
- Version:
- 1.22 07/01/98
- Author:
- Arthur van Hoff
- Since:
- JDK1.0
- See Also:
- Container
-
java.awt.CardLayout()
- Creates a new card layout with gaps of size zero.
-
java.awt.CardLayout(int, int)
- Creates a new card layout with the specified horizontal and
vertical gaps.
-
addLayoutComponent(Component, Object)
- Adds the specified component to this card layout's internal
table of names.
-
addLayoutComponent(String, Component)
-
-
first(Container)
- Flips to the first card of the container.
-
getHgap()
- Gets the horizontal gap between components.
-
getLayoutAlignmentX(Container)
- Returns the alignment along the x axis.
-
getLayoutAlignmentY(Container)
- Returns the alignment along the y axis.
-
getVgap()
- Gets the vertical gap between components.
-
invalidateLayout(Container)
- Invalidates the layout, indicating that if the layout manager
has cached information it should be discarded.
-
last(Container)
- Flips to the last card of the container.
-
layoutContainer(Container)
-
Lays out the specified container using this card layout.
-
maximumLayoutSize(Container)
- Returns the maximum dimensions for this layout given the components
in the specified target container.
-
minimumLayoutSize(Container)
-
Calculates the minimum size for the specified panel.
-
next(Container)
- Flips to the next card of the specified container.
-
preferredLayoutSize(Container)
-
Determines the preferred size of the container argument using
this card layout.
-
previous(Container)
- Flips to the previous card of the specified container.
-
removeLayoutComponent(Component)
- Removes the specified component from the layout.
-
setHgap(int)
- Sets the horizontal gap between components.
-
setVgap(int)
- Sets the vertical gap between components.
-
show(Container, String)
- Flips to the component that was added to this layout with the
specified
name
, using addLayoutComponent
.
-
toString()
- Returns a string representation of the state of this card layout.
CardLayout
public CardLayout()
- Creates a new card layout with gaps of size zero.
- Since:
- JDK1.0
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.
- Parameters:
- hgap - the horizontal gap.
- vgap - the vertical gap.
- Since:
- JDK1.0
addLayoutComponent
public void addLayoutComponent(Component comp,
Object constraints)
- 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.
- Throws: IllegalArgumentException
- if the constraint is not a string.
- Since:
- JDK1.0
- See Also:
- show(java.awt.Container, java.lang.String)
addLayoutComponent
public void addLayoutComponent(String name,
Component comp)
- Note: addLayoutComponent() is deprecated.
replaced by
addLayoutComponent(Component, Object)
.
-
first
public void first(Container parent)
- Flips to the first card of the container.
- Parameters:
- parent - the name of the parent container
in which to do the layout.
- Since:
- JDK1.0
- See Also:
- last
getHgap
public int getHgap()
- Gets the horizontal gap between components.
- Returns:
- the horizontal gap between components.
- Since:
- JDK1.1
- See Also:
- setHgap(int), getVgap()
getLayoutAlignmentX
public float getLayoutAlignmentX(Container parent)
- 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.
getLayoutAlignmentY
public float getLayoutAlignmentY(Container parent)
- 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.
getVgap
public int getVgap()
- Gets the vertical gap between components.
- Returns:
- the vertical gap between components.
- See Also:
- setVgap(int), getHgap()
invalidateLayout
public void invalidateLayout(Container target)
- Invalidates the layout, indicating that if the layout manager
has cached information it should be discarded.
last
public void last(Container parent)
- Flips to the last card of the container.
- Parameters:
- parent - the name of the parent container
in which to do the layout.
- Since:
- JDK1.0
- See Also:
- first
layoutContainer
public void layoutContainer(Container parent)
- 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.
- Since:
- JDK1.0
- See Also:
- doLayout
maximumLayoutSize
public java.awt.Dimension maximumLayoutSize(Container target)
- Returns the maximum dimensions for this layout given the components
in the specified target container.
- Parameters:
- target - the component which needs to be laid out
- See Also:
- Container, minimumLayoutSize, preferredLayoutSize
minimumLayoutSize
public java.awt.Dimension minimumLayoutSize(Container parent)
- Calculates the minimum size for the specified panel.
- Parameters:
- parent - the name of the parent container
in which to do the layout.
- Returns:
- the minimum dimensions required to lay out the
subcomponents of the specified container.
- Since:
- JDK1.0
- See Also:
- doLayout, preferredLayoutSize
next
public void next(Container parent)
- 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.
- Parameters:
- parent - the name of the parent container
in which to do the layout.
- Since:
- JDK1.0
- See Also:
- previous
preferredLayoutSize
public java.awt.Dimension preferredLayoutSize(Container parent)
- Determines the preferred size of the container argument using
this card layout.
- Parameters:
- parent - the name of the parent container.
- Returns:
- the preferred dimensions to lay out the subcomponents
of the specified container.
- Since:
- JDK1.0
- See Also:
- getPreferredSize, minimumLayoutSize
previous
public void previous(Container parent)
- 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.
- Since:
- JDK1.0
- See Also:
- next
removeLayoutComponent
public void removeLayoutComponent(Component comp)
- Removes the specified component from the layout.
- Parameters:
- comp - the component to be removed.
- Since:
- JDK1.0
- See Also:
- remove(java.awt.Component), removeAll()
setHgap
public void setHgap(int hgap)
- Sets the horizontal gap between components.
- Parameters:
- hgap - the horizontal gap between components.
- Since:
- JDK1.1
- See Also:
- getHgap(), setVgap(int)
setVgap
public void setVgap(int vgap)
- Sets the vertical gap between components.
- Parameters:
- vgap - the vertical gap between components.
- Since:
- JDK1.1
- See Also:
- getVgap(), setHgap(int)
show
public void show(Container parent,
String name)
- 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.
- name - the component name.
- Since:
- JDK1.0
- See Also:
- addLayoutComponent(java.awt.Component, java.lang.Object)
toString
public java.lang.String toString()
- Returns a string representation of the state of this card layout.
- Returns:
- a string representation of this card layout.
- Overrides:
- toString in class Object
- Since:
- JDK1.0
All Packages Class Hierarchy This Package Previous Next Index