CardLayout
is unusual. It breaks the applet into a deck of cards, each of which will normally have a panel with its own LayoutManager. Only one card appears on the screen at a time. You then flip between cards, each of which shows a different set of components. The common analogy is with HyperCard on the Mac and Toolbook on Windows. In Java this might be used for a series of data input screens, where more input is needed than can comfortably be fit on one screen. Conversely, you can use a CardLayout
for a slide show, where there's more data to be presented than will fit on one screen.
For example, this CardTest applet, one of Sun's standard demo applets,
uses a CardLayout
to flip between different layouts for the same five buttons: