Additional Exercises
Exercise 4 - Creating a complex menu
Menus usually contain text,
but it is also common to use a 'separator' (a horizontal line) to divide groups
of menu items to make them easier to read. In Java, we define a separator by
creating a new MenuItem
object whose text is '-' (a
single dash). Java recognises the dash and turns it into a separator.
With this in mind, write
the Java statements that create a menu with the following structure.
File
New
------
Open
Save
Save as?/p>
-----
Exit
Edit
Cut
Copy
Paste
Help
Contents
Search?/p>
-----
About?/p>
Discussion/Solution to
Exercise 4

|