Swing 简明教程

SWING - Menu Classes

众所周知,每个顶级窗口都与它关联有一个菜单栏。此菜单栏由最终用户使用的各种菜单选项组成。此外,每个选项都包含一个称为下拉菜单的列表。菜单和 MenuItem 控件是 MenuComponent 类的子类。

As we know that every top-level window has a menu bar associated with it. This menu bar consists of various menu choices available to the end user. Further, each choice contains a list of options, which is called drop-down menus. Menu and MenuItem controls are subclass of MenuComponent class.

Menu Hierarchy

swing menuhiearchy

Menu Controls

Sr.No.

Class & Description

1

JMenuBarThe JMenuBar object is associated with the top-level window.

2

JMenuItemThe items in the menu must belong to the JMenuItem or any of its subclass.

3

JMenuThe JMenu object is a pull-down menu component which is displayed from the menu bar.

4

JCheckboxMenuItemJCheckboxMenuItem is the subclass of JMenuItem.

5

JRadioButtonMenuItemJRadioButtonMenuItem is the subclass of JMenuItem.

6

JPopupMenuJPopupMenu can be dynamically popped up at a specified position within a component.