Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.awt

Class CardLayout

java.lang.Object
|
+--java.awt.CardLayout

All Implemented Interfaces:

LayoutManager2, Serializable


public class CardLayout

extends Object

implements LayoutManager2, Serializable

This class implements a card-based layout scheme. Each included component is treated as a card. Only one card can be shown at a time. This class includes methods for changing which card is shown.

Authors:

Constructor Summary

CardLayout()

Initializes a new instance of CardLayout with horizontal and vertical gaps of 0.
CardLayout(int hgap, int vgap)

Create a new CardLayout object with the specified horizontal and vertical gaps.

Method Summary

voidaddLayoutComponent(java.awt.Component comp, java.lang.Object constraints)

Add a new component to the layout.
voidaddLayoutComponent(java.lang.String name, java.awt.Component comp)

Add a new component to the layout.
voidfirst(java.awt.Container parent)

Cause the first component in the container to be displayed.
intgetHgap()

Return this layout manager's horizontal gap.
floatgetLayoutAlignmentX(java.awt.Container parent)

Return this layout manager's x alignment.
floatgetLayoutAlignmentY(java.awt.Container parent)

Returns this layout manager's y alignment.
intgetVgap()

Return this layout manager's vertical gap.
voidinvalidateLayout(java.awt.Container target)

Invalidate this layout manager's state.
voidlast(java.awt.Container parent)

Cause the last component in the container to be displayed.
voidlayoutContainer(java.awt.Container parent)

Lays out the container.
java.awt.DimensionmaximumLayoutSize(java.awt.Container target)

Get the maximum layout size of the container.
java.awt.DimensionminimumLayoutSize(java.awt.Container target)

Get the minimum layout size of the container.
voidnext(java.awt.Container parent)

Cause the next component in the container to be displayed.
java.awt.DimensionpreferredLayoutSize(java.awt.Container parent)

Get the preferred layout size of the container.
voidprevious(java.awt.Container parent)

Cause the previous component in the container to be displayed.
voidremoveLayoutComponent(java.awt.Component comp)

Remove the indicated component from this layout manager.
voidsetHgap(int hgap)

Set this layout manager's horizontal gap.
voidsetVgap(int vgap)

Set this layout manager's vertical gap.
voidshow(java.awt.Container parent, java.lang.String name)

Cause the named component to be shown.
java.lang.StringtoString()

Returns a string representation of this layout manager.

Constructor Details

CardLayout

public CardLayout()

Initializes a new instance of CardLayout with horizontal and vertical gaps of 0.


CardLayout

public CardLayout(int hgap, int vgap)

Create a new CardLayout object with the specified horizontal and vertical gaps.

Parameters:


Method Details

addLayoutComponent

public void addLayoutComponent(java.awt.Component comp, java.lang.Object constraints)

Add a new component to the layout. The constraint must be a string which is used to name the component. This string can later be used to refer to the particular component.

Parameters:

Throws:


addLayoutComponent

public void addLayoutComponent(java.lang.String name, java.awt.Component comp)

Add a new component to the layout. The name can be used later to refer to the component.

Parameters:


first

public void first(java.awt.Container parent)

Cause the first component in the container to be displayed.

Parameters:


getHgap

public int getHgap()

Return this layout manager's horizontal gap.


getLayoutAlignmentX

public float getLayoutAlignmentX(java.awt.Container parent)

Return this layout manager's x alignment. This method always returns Component.CENTER_ALIGNMENT.

Parameters:


getLayoutAlignmentY

public float getLayoutAlignmentY(java.awt.Container parent)

Returns this layout manager's y alignment. This method always returns Component.CENTER_ALIGNMENT.

Parameters:


getVgap

public int getVgap()

Return this layout manager's vertical gap.


invalidateLayout

public void invalidateLayout(java.awt.Container target)

Invalidate this layout manager's state.

Parameters:


last

public void last(java.awt.Container parent)

Cause the last component in the container to be displayed.

Parameters:


layoutContainer

public void layoutContainer(java.awt.Container parent)

Lays out the container. This is done by resizing the child components to be the same size as the parent, less insets and gaps.

Parameters:


maximumLayoutSize

public Dimension maximumLayoutSize(java.awt.Container target)

Get the maximum layout size of the container.

Parameters:


minimumLayoutSize

public Dimension minimumLayoutSize(java.awt.Container target)

Get the minimum layout size of the container.

Parameters:


next

public void next(java.awt.Container parent)

Cause the next component in the container to be displayed. If this current card is the last one in the deck, the first component is displayed.

Parameters:


preferredLayoutSize

public Dimension preferredLayoutSize(java.awt.Container parent)

Get the preferred layout size of the container.

Parameters:


previous

public void previous(java.awt.Container parent)

Cause the previous component in the container to be displayed. If this current card is the first one in the deck, the last component is displayed.

Parameters:


removeLayoutComponent

public void removeLayoutComponent(java.awt.Component comp)

Remove the indicated component from this layout manager.

Parameters:


setHgap

public void setHgap(int hgap)

Set this layout manager's horizontal gap.

Parameters:


setVgap

public void setVgap(int vgap)

Set this layout manager's vertical gap.

Parameters:


show

public void show(java.awt.Container parent, java.lang.String name)

Cause the named component to be shown. If the component name is unknown, this method does nothing.

Parameters:


toString

public String toString()

Returns a string representation of this layout manager.

Returns: