Using the CardLayout Manager

CardLayout places components on top of each other like a deck of cards. Only one component will be visible at any given time. After the components are placed on the container, you must develop code to cycle through the given cards.

When to Use CardLayout

CardLayout is particularly good when you have an area that contains different components at different times. This gives you a way to manage many panels that need to share the same frame. You then will create a component that cycles the user through the components within the container. Figure 12.6 shows a sample of how CardLayout manages components.

Figure 12.6. CardLayout sample display.

With the introduction of JTabbedPane, CardLayout is not as useful as it ...

Get Borland® JBuilder™ Developer’s Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.