Package java.awt Previous
Previous
Java API
Java API
Index
Index
Next
Next

Class CardLayout

Constructors , Methods

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.


Constructors


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.

ParameterDescription
hgap the horizontal gap
vgap the vertical gap


Methods


addLayoutComponent

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.

ParameterDescription
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.

ParameterDescription
target the container in which to do the layout


last

public void last(Container  target) 

Flips to the last card of the container.

ParameterDescription
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 .

ParameterDescription
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 .

Return Value:

Returns the minimum dimensions needed to lay out the subcomponents of the specified container.

ParameterDescription
target the container in which to do the layout

See Also: preferredLayoutSize .


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.

ParameterDescription
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 .

Return Value:

Returns the preferred dimensions to lay out the subcomponents of the specified container.

ParameterDescription
target the container in which to do the layout

See Also: minimumLayoutSize .


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.

ParameterDescription
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 or removeAll methods. Most applications do not call this method directly.

ParameterDescription
comp the component to be removed


show

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.

ParameterDescription
target the container in which to do the layout
name a tag


toString

public String toString() 

Return Value:

Returns a String representation of this card layout.

Overrides:

toString in class Object .



Top© 1996 Sun Microsystems, Inc. All rights reserved.