Package java.awt |
![]() Previous |
![]() Java API |
![]() Index |
![]() Next |
public class java.awt.CardLayout extends java.lang.Object implements java.awt.LayoutManager { // Constructors public CardLayout(); public CardLayout(int hgap, int vgap); // Methods public void addLayoutComponent(String name, Component comp); public void first(Container target); public void last(Container target); public void layoutContainer(Container target); public Dimension minimumLayoutSize(Container target); public void next(Container target); public Dimension preferredLayoutSize(Container target); public void previous(Container target); public void removeLayoutComponent(Component comp); public void show(Container target, String name); public String toString(); }
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.
public CardLayout()Creates a new card layout.
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.
Parameter Description hgap the horizontal gap vgap the vertical gap
public void addLayoutComponent(String name, Component comp)Adds the specified component to the card layout using the indicated name tag. The show method can be used to display the component with the specified tag.
Parameter Description name a tag understood by the layout manager comp the component to be added
public void first(Container target)Flips to the first card of the container.
Parameter Description target the container in which to do the layout
public void last(Container target)Flips to the last card of the container.
Parameter Description target the container in which to do the layout
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 .
Parameter Description target the container in which to do the layout
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 .
Return Value:
Returns the minimum dimensions needed to lay out the subcomponents of the specified container.
Parameter Description target the container in which to do the layout See Also: preferredLayoutSize .
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.
Parameter Description target the container in which to do the layout.
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 .
Return Value:
Returns the preferred dimensions to lay out the subcomponents of the specified container.
Parameter Description target the container in which to do the layout See Also: minimumLayoutSize .
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.
Parameter Description target the container in which to do the layout
public void removeLayoutComponent(Component comp)Removes the specified component from the layout.
This method is called when a container calls its remove or removeAll methods. Most applications do not call this method directly.
Parameter Description comp the component to be removed
public void show(Container target, String name)Flips to the component that was added to this layout with the specified name tag. If no such component exists, then nothing happens.
Parameter Description target the container in which to do the layout name a tag
public String toString()Return Value:
Returns a String representation of this card layout.
Overrides:
toString in class Object .