Creating a JMenuBar
In Swing, the JMenuBar class displays a menu bar on the window or frame.
The JMenu class is a pull-down menu displayed from the menu bar.
The JMenuItem class adds a labeled menu item.
Steps to orgainzing a Menu Bar:
1. Create a JMenuBar
2. Attach JMenu to the bar
3. Add JMenuItems to the JMenu
4. Add JMenuBar to the panel
Note: The JMenuItems are added to the JMenu, which is added to the JMenuBar, which is added to the JPanel. Only the JMenuBar is added to the JPanel.
Create and Activate a JMenuBar: |
|
|
Example: The user is given a menu-drop-down EDIT showing four choices. The user picks a choice which triggers a message to be displayed.