Home » openjdk-7 » java » awt » [javadoc | source]
java.awt
public class: CardLayout [javadoc | source]
java.lang.Object
   java.awt.CardLayout

All Implemented Interfaces:
    LayoutManager2, java$io$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 CardLayout#addLayoutComponent method can be used to associate a string identifier with a given card for fast random access.

Nested Class Summary:
class  CardLayout.Card   
Field Summary
 Vector vector     
 int currentCard     
 int hgap     
 int vgap     
Constructor:
 public CardLayout() 
 public CardLayout(int hgap,
    int vgap) 
Method from java.awt.CardLayout Summary:
addLayoutComponent,   addLayoutComponent,   checkLayout,   first,   getHgap,   getLayoutAlignmentX,   getLayoutAlignmentY,   getVgap,   invalidateLayout,   last,   layoutContainer,   maximumLayoutSize,   minimumLayoutSize,   next,   preferredLayoutSize,   previous,   removeLayoutComponent,   setHgap,   setVgap,   show,   showDefaultComponent,   toString
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from java.awt.CardLayout Detail:
 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.
 public  void addLayoutComponent(String name,
    Component comp) 
Deprecated! replaced - by addLayoutComponent(Component, Object).

  void checkLayout(Container parent) 
    Make sure that the Container really has a CardLayout installed. Otherwise havoc can ensue!
 public  void first(Container parent) 
    Flips to the first card of the container.
 public int getHgap() 
    Gets the horizontal gap between components.
 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.
 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.
 public int getVgap() 
    Gets the vertical gap between components.
 public  void invalidateLayout(Container target) 
    Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.
 public  void last(Container parent) 
    Flips to the last card of the container.
 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.

 public Dimension maximumLayoutSize(Container target) 
    Returns the maximum dimensions for this layout given the components in the specified target container.
 public Dimension minimumLayoutSize(Container parent) 
    Calculates the minimum size for the specified panel.
 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.
 public Dimension preferredLayoutSize(Container parent) 
    Determines the preferred size of the container argument using this card layout.
 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.
 public  void removeLayoutComponent(Component comp) 
    Removes the specified component from the layout. If the card was visible on top, the next card underneath it is shown.
 public  void setHgap(int hgap) 
    Sets the horizontal gap between components.
 public  void setVgap(int vgap) 
    Sets the vertical gap between components.
 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.
  void showDefaultComponent(Container parent) 
 public String toString() 
    Returns a string representation of the state of this card layout.