![]() |
Flipping through components
PrerequisitesIn this exercise you will create an applet with two "cards" with a Bean component on each one, laying them out with CardLayout. Work LocationPerform all work for this magercise in VisualAge project MageLang Magercises, package magercises.flipcomp. If this project does not appear in your Workspace add it from the repository (if it exists there) or create a new project using this name. Tasks
Perform the following tasks:
We need the button to flip between the various components that the card layout panel will hold. This requires using the next method of CardLayout. We can access the layout manager of the panel, but it will be of type LayoutManager, which doesn't have the next method. So we need to: Now, when the button is pressed, it changes the currently-displayed component on the CardLayout panel. Add the CompassPoints and PhonePadTest beans from the previous exercises to the panel. You will notice that when you add the second bean, the first disappears; this is a property of the CardLayout layout manager. The first button you added is still there, it's just hidden for the time-being. If you wish to see the first bean, use the Tools->Beans List menu item to open a window containing a "nested folder" view of the beans in your applet. By expand all the folders via clicking on the plus icons, you can see all the beans contained within your applet. Clicking on CompassPoints1 will bring it back to the front.
|
Copyright © 1996-1997 MageLang Institute. All Rights Reserved. |