Packages This Package Prev Next Index
§1.4 Class CardLayout
public class java.awt.CardLayout
extends java.lang.Object (I-§1.12)
implements java.awt.LayoutManager (II-§1.43)
{
// Constructors
public CardLayout(); §1.4.1
public CardLayout(int hgap, int vgap); §1.4.2
// Methods
public void addLayoutComponent(String name, Component comp); §1.4.3
public void first(Container target); §1.4.4
public void last(Container target); §1.4.5
public void layoutContainer(Container target); §1.4.6
public Dimension minimumLayoutSize(Container target); §1.4.7
public void next(Container target); §1.4.8
public Dimension preferredLayoutSize(Container target); §1.4.9
public void previous(Container target); §1.4.10
public void removeLayoutComponent(Component comp); §1.4.11
public void show(Container target, String name); §1.4.12
public String toString(); §1.4.13
}
A layout manager for a container that contains several "cards". Only one card is visible at
a time, allowing the application to flip through the cards.
CardLayout
public CardLayout()
- Creates a new card layout.
CardLayout
public CardLayout(int hgap, int vgap)
- Creates a new card layout with the specified horizontal and vertical gaps.
The horizontal gaps are placed and the left and right edge. The vertical
gaps are placed at the top and bottom edge.
- Parameters:
hgap
-
the horizontal gap
vgap
-
the vertical gap
addLayoutComponent
public void addLayoutComponent(String name, Component comp)
- Adds the specified component to the card layout using the indicated name
tag. The show method (II-§1.4.12) can be used to display the component
with the specified tag.
- Parameters:
name
-
a tag understood by the layout manager
comp
-
the component to be added
first
public void first(Container target)
- Flips to the first card of the container.
- Parameters:
target
-
the container in which to do the layout
last
public void last(Container target)
- Flips to the last card of the container.
- Parameters:
target
-
the container in which to do the layout
layoutContainer
public void layoutContainer(Container target)
- Lays out the container argument using this card layout.
- Each component in the target container is reshaped to be the size of the
container minus space for surrounding insets, horizontal gaps, and vertical
gaps.
- Most applications do not call this method directly. This method is called
when a container calls its layout method (II-§1.11.11).
- Parameters:
target
-
the container in which to do the layout
minimumLayoutSize
public Dimension minimumLayoutSize(Container target)
- Determines the minimum size of the container argument using this card
layout.
- The minimum width of a card layout is the largest minimum width of the
cards in the container, plus twice the horizontal gap, plus the left and right
insets.
- The minimum height of a card layout is the largest minimum height of the
cards in the container, plus twice the vertical gap, plus the top and bottom
insets.
- Most applications do not call this method directly. This method is called
when a container calls its layout method (II-§1.11.11).
- Parameters:
target
-
the container in which to do the layout
- Returns:
- the minimum dimensions needed to lay out the subcomponents of the
specified container.
- See Also:
- preferredLayoutSize (II-§1.4.9).
next
public void next(Container target)
- 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:
target
-
the container in which to do the layout.
preferredLayoutSize
public Dimension preferredLayoutSize(Container target)
- Determines the preferred size of the container argument using this card
layout.
- The preferred width of a card layout is the largest preferred width of the
cards in the container, plus twice the horizontal gap, plus the left and right
insets.
- The preferred height of a card layout is the largest preferred height of the
cards in the container, plus twice the vertical gap, plus the top and bottom
insets.
- Most applications do not call this method directly. This method is called
when a container calls its preferredSize method (II-§1.11.17).
- Parameters:
target
-
the container in which to do the layout
- Returns:
- the preferred dimensions to lay out the subcomponents of the specified container.
- See Also:
- minimumLayoutSize (II-§1.4.7).
previous
public void previous(Container target)
- 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:
target
-
the container in which to do the layout
removeLayoutComponent
public void removeLayoutComponent(Component comp)
- Removes the specified component from the layout.
- This method is called when a container calls its remove (II-§1.11.19) or
removeAll (II-§1.11.20) methods. Most applications do not call this method
directly.
- Parameters:
comp
-
the component to be removed
show
public void show(Container target, String name)
- Flips to the component that was added to this layout (II-§1.4.3) with the
specified name tag. If no such component exists, then nothing happens.
- Parameters:
target
-
the container in which to do the layout
name
-
a tag
toString
public String toString()
- Returns:
- a String representation of this card layout.
- Overrides:
- toString in class Object (I-§1.12.9).
Packages This Package Prev Next Index
Java API Document (HTML generated by dkramer on April 22, 1996)
Copyright © 1996 Sun Microsystems, Inc.
All rights reserved
Please send any comments or corrections to doug.kramer@sun.com