1000 Java Tips ebook
Free "1000 Java Tips" eBook is here! It is huge collection of big and small Java
programming articles and tips. Please take your copy here.
Take your copy of free "Java Technology Screensaver"!.
JavaFAQ Home » Swing, AWT
A menu bar can be added to the top of any top-level containers (
JFrame, JApplet, JDialog, and less commonly JInternalFrame, JRootPane). Note
that it can not be added to JPanel.
Think of a menu as a way to arrange buttons.
Types of menus
- Dropdown menus hang down from the menu bar
at the top of a window.
- Popup menus appear when the user clicks, eg with
the right mouse button, on a component that can handle a popup request.
- Combo boxes are like menus that always shows one item.
Similary, there are lists and radio buttons.
JMenuBar, JMenu, and JMenuItem
Dropdown menus have three parts:
- JMenuBar is positioned across the top of a container (eg
a JFrame, JPanel, or JApplet). It's placed above the content pane, so does
not use the container's layout. Add menus to the menubar.
- JMenu is a vertical list of menu items.
- JMenuItem and Separators are added to
each menu. Menu items are usually strings, but can also have icons,
checkboxes, or hierarchical submenus.
Menus and Menu Items are Buttons!
It is easy to see how menu items are buttons that appear when a menu appears.
But the menu names in the menu bar are also buttons. When you press on these
"buttons", they create a popup menu that you see as a dropdown menu.
Printer Friendly Page
Send to a Friend
Search here again if you need more info!