JMenuBar, JMenu, and JMenuItem Classes

This section describes 3 Swing classes, JMenuBar, JMenu, and JMenuItem, to build a menu interface for a frame window. A typical menu interface has a menu bar with multiple menus or menu items. A menu can have multiple sub menus or menu items.

javax.swing.JMenuBar - A Swing class representing the menu bar on the main frame. javax.swing.JMenu objects added a JMenuBar object will be displayed horizontally. Interesting methods of JMenuBar include:

javax.swing.JMenu - A Swing class representing a user interface menu. A JMenu object can be added to a JMenuBar or another JMenu object to form a menu tree structure. A JMenu object actually has two graphical components, a clickable button displayed in the parent JMenu or JMenuBar and a popup window. When its button is clicked, its pop up window will be displayed. Interesting methods of JMenu include:

javax.swing.JMenuItem - A Swing class representing a user interface menu item. A JMenuItem object can be added to a JMenuBar or another JMenu object in a menu tree structure. A JMenuItem should be associated with a MenuKeyListener object so that tasks can be performed with the menu item is clicked. Interesting methods of JMenuItem include:

Table of Contents

 About This Book

 JDK (Java Development Kit)

 Introduction of Java Swing Package

 Graphics Environment of the Local System

 JFrame - Main Frame Class

 JLabel - Swing Label Class

 JButton - Swing Button Class

 JCheckBox - Swing Check Box Class

 JRadioButton - Swing Radio Button Class

 JTextField - Swing Text Field Class

 JComboBox - Swing Combo Box Class

Menu Bar, Menus, Menu Items and Listeners

JMenuBar, JMenu, and JMenuItem Classes

 JMenuBarTest.java - Menu Bar Test Program

 JMenuTest.java - Menu Test Program

 JMenuItemTest.java - Menu Item Test Program

 JRadioButtonMenuItemTest.java - Radio Button Menu Item Test Program

 JCheckBoxMenuItemTest.java - Check Box Menu Item Test Program

 javax.swing.event.MenuListener - Menu Listener Interface

 JMenuItemActionListenerTest.java - Menu Item Action Listener Test

 Item Listener on Radio Button Menu Items

 Item Listener on Check Box Menu Items

 javax.swing.event.MenuKeyListener - Menu Key Listener Interface

 setMnemonic() - Setting Keyboard Mnemonics on Menu Items

 setAccelerator() - Setting Keyboard Accelerators on Menu Items

 setMnemonic() - Setting Keyboard Mnemonics on Menus

 Creating Internal Frames inside the Main Frame

 Layout of Components in a Container

 LookAndFeel and UIManager

 Option Dialog Boxes

 JEditorPane - The Editor Pane Class

 SwingWorker - The Background Task Worker

 AWT (Abstract Windows Toolkit)

 Integration with Desktop System

 Archived Tutorials

 References

 Full Version in PDF/EPUB