What is the difference between JMenuItem and JMenu?
JMenu m;
JMenuItem i;
What is the difference between JMenuItem and JMenu?
JMenu m;
JMenuItem i;
A JMenu
is the menu itself, or as the documentation states:
An implementation of a menu -- a popup window containing
JMenuItem
s that is displayed when the user selects an item on theJMenuBar
.
A JMenuItem
is a single item in such a menu. Or, as the documentation describes it:
An implementation of an item in a menu. A menu item is essentially a button sitting in a list. When the user selects the "button", the action associated with the menu item is performed.
JMenu extends JMenuItem. The different is that JMenu is an item which can contain other JMenuItems. Think of it as being a SubMenu.