Menus


In this Magercise, you will create an applet that constructs a Frame containing a "File" menu, and a "Help" menu that uses all the MenuItem objects.

An OS/2 C version of this Magercise exists in this directory. Note that the behavior of the C program may not be the same as the Magercise -- it is presented here for comparision against the Java application you will write in this Magercise. One of the major differences is that the C version does not support layout managers, so resizing a window will not resize the contents of that window.

Work Location

Perform all work for this magercise in VisualAge project MageLang Magercises, package magercises.menus.

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:

  1. Create an applet called MenuTest. Add a Frame bean to the applet and connect the applet's componentShown method to the frame's show method.

    Also add a TextField bean to the frame.

  2. Add a MenuBar bean to the frame with two menus:
    1. File should contain:
      1. Open
      2. Close
      3. Exit
    2. Help should contain:
      1. Fundamentals
      2. Advanced
      3. - (a separator)
      4. Have Read The Manual (as a CheckboxMenuItem)
      5. Have Read The Tutorial (as a CheckboxMenuItem)
      6. Misc (submenu) with:
        1. Sub-item 1
        2. Sub-item 2

  3. For each MenuItem and CheckBoxMenuItem, create a connection such that a user selecting the menu-item causes the textfield to display the menu-item's label.

The task numbers above are linked to the step-by-step help page. Also available is a complete solution to the problem, and expected behavior, to demonstrate it.

Copyright © 1996-1997 MageLang Institute. All Rights Reserved.