Home » Java JMenuBar, JMenu and JMenuItem

Java JMenuBar, JMenu and JMenuItem

by Online Tutorials Library

Java JMenuBar, JMenu and JMenuItem

The JMenuBar class is used to display menubar on the window or frame. It may have several menus.

The object of JMenu class is a pull down menu component which is displayed from the menu bar. It inherits the JMenuItem class.

The object of JMenuItem class adds a simple labeled menu item. The items used in a menu must belong to the JMenuItem or any of its subclass.


JMenuBar class declaration

JMenu class declaration

JMenuItem class declaration


Java JMenuItem and JMenu Example

Output:

JAVA Jmenuitem and jmenu 1


Example of creating Edit menu for Notepad:

Output:

JAVA Jmenuitem and jmenu 2

Next TopicJava JPopupMenu

You may also like