![]() |
Help: Flipping through components
Help is available for each task, or you can go straight to the solution source code.
Let's put the button at the bottom of the applet, and the panel in the rest. To do this, set the applet's layout manager to BorderLayout. Add a button at the bottom ("South") edge, then add a panel in the center. Set the panel's layout to CardLayout. Task 2We 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. No additional help. Task 3Add 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. To add the beans, use the Options->Add Bean... menu-item. When the dialog appears, click the Browse... button and type CardLayout then click OK. Repeat the same process for the PhonePadTest bean.
No additional help. |
Copyright © 1996-1997 MageLang Institute. All Rights Reserved. |