 




|
|
Help: Menus
Help is available for each task, or you can go straight to
the solution source code.
Task 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.
To make the connection, left-click on the applet, select
Connect->All features... and select
Event->componentShown(java.awt.ComponentEvent) in the dialog
box that appears; click OK.
Now move your mouse to the Frame, click then select show().
Task 2
Add a MenuBar bean to the frame with two menus:
- File should contain:
- Open
- Close
- Exit
- Help should contain:
- Fundamentals
- Advanced
- - (a separator)
- Have Read The Manual (as a CheckboxMenuItem)
- Have Read The Tutorial (as a CheckboxMenuItem)
- Misc (submenu) with:
- Sub-item 1
- Sub-item 2
To add the menus to the menubar, drop the Menu bean onto the
the menubar contained within the frame.
To add menu-items to the menus, drop the MenuItem beans
onto the gray windows representing the menus.
To add a sub-menu, drop a MenuBar bean onto the
Help window.
Task 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.
To complete this task you actually need to create two connections for each menu-item:
- An event-to-method connection between the menu-item's actionPerformedEvent and the textfield's text method.
- A property-to-property connection between the above connection's value property and the label property of the menu-item.
For the CheckboxMenuItems, connect the
itemStateChanged (instead of the
actionPerformedEvent) event to the text method of the
textfield.
|