public class CardLayout extends Object implements LayoutManager2, Serializable
Constructor and Description |
---|
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. |
Modifier and Type | Method and Description |
---|---|
void |
addLayoutComponent(Component comp,
Object constraints)
Add a new component to the layout.
|
void |
addLayoutComponent(String name,
Component comp)
Deprecated.
This method is deprecated in favor of
addLayoutComponent(Component, Object) . |
void |
first(Container parent)
Cause the first component in the container to be displayed.
|
int |
getHgap()
Return this layout manager's horizontal gap.
|
float |
getLayoutAlignmentX(Container parent)
Return this layout manager's x alignment.
|
float |
getLayoutAlignmentY(Container parent)
Returns this layout manager's y alignment.
|
int |
getVgap()
Return this layout manager's vertical gap.
|
void |
invalidateLayout(Container target)
Invalidate this layout manager's state.
|
void |
last(Container parent)
Cause the last component in the container to be displayed.
|
void |
layoutContainer(Container parent)
Lays out the container.
|
Dimension |
maximumLayoutSize(Container target)
Get the maximum layout size of the container.
|
Dimension |
minimumLayoutSize(Container target)
Get the minimum layout size of the container.
|
void |
next(Container parent)
Cause the next component in the container to be displayed.
|
Dimension |
preferredLayoutSize(Container parent)
Get the preferred layout size of the container.
|
void |
previous(Container parent)
Cause the previous component in the container to be displayed.
|
void |
removeLayoutComponent(Component comp)
Remove the indicated component from this layout manager.
|
void |
setHgap(int hgap)
Set this layout manager's horizontal gap.
|
void |
setVgap(int vgap)
Set this layout manager's vertical gap.
|
void |
show(Container parent,
String name)
Cause the named component to be shown.
|
String |
toString()
Returns a string representation of this layout manager.
|
public CardLayout()
CardLayout
with horizontal
and vertical gaps of 0.public CardLayout(int hgap, int vgap)
CardLayout
object with the specified
horizontal and vertical gaps.hgap
- The horizontal gapvgap
- The vertical gappublic void addLayoutComponent(Component comp, Object constraints)
addLayoutComponent
in interface LayoutManager2
comp
- The component to addconstraints
- The name by which the component can later be calledIllegalArgumentException
- If `constraints' is not a
String
public void addLayoutComponent(String name, Component comp)
addLayoutComponent(Component, Object)
.addLayoutComponent
in interface LayoutManager
name
- The name by which the component can later be calledcomp
- The component to addpublic void first(Container parent)
parent
- The parent container, not null
.public int getHgap()
public float getLayoutAlignmentX(Container parent)
getLayoutAlignmentX
in interface LayoutManager2
parent
- Container using this layout manager instancepublic float getLayoutAlignmentY(Container parent)
getLayoutAlignmentY
in interface LayoutManager2
parent
- Container using this layout manager instancepublic int getVgap()
public void invalidateLayout(Container target)
invalidateLayout
in interface LayoutManager2
target
- the target containerpublic void last(Container parent)
parent
- The parent container, not null
.public void layoutContainer(Container parent)
layoutContainer
in interface LayoutManager
parent
- The parent container.public Dimension maximumLayoutSize(Container target)
maximumLayoutSize
in interface LayoutManager2
target
- The parent containerComponent.getMaximumSize()
public Dimension minimumLayoutSize(Container target)
minimumLayoutSize
in interface LayoutManager
target
- The parent containerLayoutManager.preferredLayoutSize(Container)
public void next(Container parent)
parent
- The parent container, not null
.public Dimension preferredLayoutSize(Container parent)
preferredLayoutSize
in interface LayoutManager
parent
- The parent containerLayoutManager.minimumLayoutSize(Container)
public void previous(Container parent)
parent
- The parent container, not null
.public void removeLayoutComponent(Component comp)
removeLayoutComponent
in interface LayoutManager
comp
- The component to removepublic void setHgap(int hgap)
hgap
- The new gappublic void setVgap(int vgap)
vgap
- The new gappublic void show(Container parent, String name)
null
, this method does nothing.parent
- The parent container, not null
.name
- The name of the component to showpublic String toString()
toString
in class Object
Object.getClass()
,
Object.hashCode()
,
Class.getName()
,
Integer.toHexString(int)