public class OverlappingLayout extends Object implements LayoutManager2, Serializable
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 addLayoutComponent(java.awt.Component, java.lang.Object)
method can be used to associate a string identifier with a given card
for fast random access.
Container,
Serialized Form| Constructor and Description |
|---|
OverlappingLayout()
Creates a new card layout with gaps of size zero.
|
OverlappingLayout(int hgap,
int vgap)
Creates a new card layout with the specified horizontal and
vertical gaps.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addLayoutComponent(Component comp,
Object constraints)
Adds the specified component to this card layout's internal
table of names.
|
void |
addLayoutComponent(String name,
Component comp)
Deprecated.
replaced by
addLayoutComponent(Component, Object). |
int |
getHgap()
Gets the horizontal gap between components.
|
float |
getLayoutAlignmentX(Container parent)
Returns the alignment along the x axis.
|
float |
getLayoutAlignmentY(Container parent)
Returns the alignment along the y axis.
|
int |
getVgap()
Gets the vertical gap between components.
|
void |
invalidateLayout(Container target)
Invalidates the layout, indicating that if the layout manager
has cached information it should be discarded.
|
void |
layoutContainer(Container parent)
Lays out the specified container using this card layout.
|
Dimension |
maximumLayoutSize(Container target)
Returns the maximum dimensions for this layout given the components
in the specified target container.
|
Dimension |
minimumLayoutSize(Container parent)
Calculates the minimum size for the specified panel.
|
Dimension |
preferredLayoutSize(Container parent)
Determines the preferred size of the container argument using
this card layout.
|
void |
removeLayoutComponent(Component comp)
Removes the specified component from the layout.
|
void |
setHgap(int hgap)
Sets the horizontal gap between components.
|
void |
setVgap(int vgap)
Sets the vertical gap between components.
|
String |
toString()
Returns a string representation of the state of this card layout.
|
public OverlappingLayout()
public OverlappingLayout(int hgap,
int vgap)
hgap - the horizontal gap.vgap - the vertical gap.public int getHgap()
CardLayout.setHgap(int),
CardLayout.getVgap()public void setHgap(int hgap)
hgap - the horizontal gap between components.CardLayout.getHgap(),
CardLayout.setVgap(int)public int getVgap()
CardLayout.setVgap(int),
CardLayout.getHgap()public void setVgap(int vgap)
vgap - the vertical gap between components.CardLayout.getVgap(),
CardLayout.setHgap(int)public void addLayoutComponent(Component comp, Object constraints)
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.addLayoutComponent in interface LayoutManager2comp - the component to be added.constraints - a tag that identifies a particular
card in the layout.IllegalArgumentException - if the constraint is not a string.CardLayout.show(java.awt.Container, java.lang.String)@Deprecated public void addLayoutComponent(String name, Component comp)
addLayoutComponent(Component, Object).addLayoutComponent in interface LayoutManagerpublic void removeLayoutComponent(Component comp)
removeLayoutComponent in interface LayoutManagercomp - the component to be removed.Container.remove(java.awt.Component),
Container.removeAll()public Dimension preferredLayoutSize(Container parent)
preferredLayoutSize in interface LayoutManagerparent - the parent container in which to do the layoutContainer.getPreferredSize(),
CardLayout.minimumLayoutSize(java.awt.Container)public Dimension minimumLayoutSize(Container parent)
minimumLayoutSize in interface LayoutManagerparent - the parent container in which to do the layoutContainer.doLayout(),
CardLayout.preferredLayoutSize(java.awt.Container)public Dimension maximumLayoutSize(Container target)
maximumLayoutSize in interface LayoutManager2target - the component which needs to be laid outContainer,
minimumLayoutSize(java.awt.Container),
preferredLayoutSize(java.awt.Container)public float getLayoutAlignmentX(Container parent)
getLayoutAlignmentX in interface LayoutManager2public float getLayoutAlignmentY(Container parent)
getLayoutAlignmentY in interface LayoutManager2public void invalidateLayout(Container target)
invalidateLayout in interface LayoutManager2public void layoutContainer(Container parent)
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.
layoutContainer in interface LayoutManagerparent - the parent container in which to do the layoutContainer.doLayout()Copyright © 2023. All rights reserved.