LayoutManager
, LayoutManager2
, 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 addLayoutComponent(java.awt.Component, java.lang.Object)
method can be used to associate a string identifier with a given card for fast random access.
Constructors
Creates a new card layout with gaps of size zero.
Creates a new card layout with the specified horizontal and vertical gaps.
void
Adds the specified component to this card layout's internal table of names.
void
void
Flips to the first card of the container.
int
Gets the horizontal gap between components.
float
Returns the alignment along the x axis.
float
Returns the alignment along the y axis.
int
Gets the vertical gap between components.
void
Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.
void
Flips to the last card of the container.
void
Lays out the specified container using this card layout.
Returns the maximum dimensions for this layout given the components in the specified target container.
Calculates the minimum size for the specified panel.
void
Flips to the next card of the specified container.
Determines the preferred size of the container argument using this card layout.
void
Flips to the previous card of the specified container.
void
Removes the specified component from the layout.
void
Sets the horizontal gap between components.
void
Sets the vertical gap between components.
void
Flips to the component that was added to this layout with the specified name
, using addLayoutComponent
.
Returns a string representation of the state of this card layout.
public CardLayout()
Creates a new card layout with gaps of size zero.
public CardLayout(int hgap, int vgap)
Creates a new card layout with the specified horizontal and vertical gaps. The horizontal gaps are placed at the left and right edges. The vertical gaps are placed at the top and bottom edges.
hgap
- the horizontal gap.
vgap
- the vertical gap.
public int getHgap()
Gets the horizontal gap between components.
public void setHgap(int hgap)
Sets the horizontal gap between components.
hgap
- the horizontal gap between components.
public int getVgap()
Gets the vertical gap between components.
public void setVgap(int vgap)
Sets the vertical gap between components.
vgap
- the vertical gap between components.
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.
addLayoutComponent
in interface LayoutManager2
comp
- the component to be added.
constraints
- a tag that identifies a particular card in the layout.
IllegalArgumentException
- if the constraint is not a string.
If the layout manager uses a per-component string, adds the component comp
to the layout, associating it with the string specified by name
.
addLayoutComponent
in interface LayoutManager
name
- the string to be associated with the component
comp
- the component to be added
Removes the specified component from the layout. If the card was visible on top, the next card underneath it is shown.
removeLayoutComponent
in interface LayoutManager
comp
- the component to be removed.
Determines the preferred size of the container argument using this card layout.
preferredLayoutSize
in interface LayoutManager
parent
- the parent container in which to do the layout
Calculates the minimum size for the specified panel.
minimumLayoutSize
in interface LayoutManager
parent
- the parent container in which to do the layout
Returns the maximum dimensions for this layout given the components in the specified target container.
maximumLayoutSize
in interface LayoutManager2
target
- the component which needs to be laid out
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.
getLayoutAlignmentX
in interface LayoutManager2
parent
- the target container
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.
getLayoutAlignmentY
in interface LayoutManager2
parent
- the target container
Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.
invalidateLayout
in interface LayoutManager2
target
- the target container
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 LayoutManager
parent
- the parent container in which to do the layout
Flips to the first card of the container.
parent
- the parent container in which to do the layout
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.
parent
- the parent container in which to do the layout
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.
parent
- the parent container in which to do the layout
Flips to the last card of the container.
parent
- the parent container in which to do the layout
Flips to the component that was added to this layout with the specified name
, using addLayoutComponent
. If no such component exists, then nothing happens.
parent
- the parent container in which to do the layout
name
- the component name
Returns a string representation of the state of this card layout.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4