CardLayout places components (usually panels) on top of
each other in a stack like a deck of cards. You see only one at a time,
and you can flip through the panels by using another control to select
which panel comes to the top.
CardLayout is a good layout to use when you have an area
that can contain different components at different times. This gives you
a way to manage two or more panels that need to share the same display
space.
An example of using CardLayout can be seen by looking at
the wizards in JDeveloper. The Cancel,
Next, and Back buttons control which panel
is displayed next.
To create a CardLayout container:
layout property to
CardLayout.
CardLayout panel. This new
panel will completely fill up the CardLayout panel.
Note:The first component you add to a
CardLayout panel will always fill the panel.
layout property for this new panel to
XYLayout and add the desired components.
CardLayout panel in the component tree in the Structure window
to add it to the stack in CardLayout panel.
XYlayout and add components to
it.
Specifying the Gap Surrounding a CardLayout Container
Using the Structure window, you can specify the amount of horizontal and
vertical gap surrounding a stack of components in a CardLayout
.
To specify the horizontal and vertical gap in a CardLayout:
cardLayout object in the Structure window,
displayed immediately below the container it controls.
hgap (horizontal gap) or vgap
(vertical gap) property in the Inspector.
Copyright © 1997, 2004, Oracle. All rights reserved.