datalogo
Return to Unit Menu |  JavaBitsNotebook.com | MathBits.com | Terms of Use  | JavaMathBits.com

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.

dividerdash

JMenuBar

reddot JMenuBar( ) - creates a new menu bar
reddot JMenu( ) - creates a menu, a pop-up window containing JMenuItems which are displayed when the user selects a choice from the JMenuBar.
reddot JMenuItem( ) - creates an item in the menu. When selected by the user, it will perform some action.

dividerdash

reddot 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.

mmpicmmpic2

mm1 
  mm2

divider
Return to Unit Menu |  JavaBitsNotebook.com | MathBits.com | Terms of Use  | JavaMathBits.com

Notice: These materials are free for your on-line use at this site, but are not free for the taking.
Please do not copy these materials or re-post them to the Internet, as it is copyright infringement.
If you wish hard-copies of these materials, refer to our subscription area, JavaMathBits.com.
Help us keep these resources free. Thank you.