Category: Menus and Toolbars

Menus and Toolbars

Using a Separator Outside of a Menu

Using a Separator Outside of a Menu

We’ve already seen how a separator can be used in menus to highlight the grouping of menu items. However, separators are components in themselves and can be used for a variety of tasks. Here...

Using Checkbox Menu Items

Using Checkbox Menu Items

Here’s a program using the JCheckBoxMenuItem class. It is similar to the JMenu example, except that each menu item now has a checkmark next to it. We’ve done nothing to make the items mutually...

The JMenu Class

The JMenu Class

The JMenu class represents the anchored menus attached to a JMenuBar or another JMenu. Menus directly attached to a menu bar are called top-level menus. Submenus, on the other hand, are not attached to...

The JPopupMenu Class

The JPopupMenu Class

Pop-up menus are an increasingly popular user-interface feature. These menus are not attached to a menu bar; instead, they are free-floating menus that associate themselves with an underlying component. This component is called the...

Introducing Swing Menus

Introducing Swing Menus

Swing menu components are subclasses of JComponent. Consequently, they have all the benefits of a Swing component, and you can treat them as such with respect to layout managers and containers.   Here are...