Example usage for java.awt Menu add

List of usage examples for java.awt Menu add

Introduction

In this page you can find the example usage for java.awt Menu add.

Prototype

public void add(String label) 

Source Link

Document

Adds an item with the specified label to this menu.

Usage

From source file:org.rapidcontext.app.ui.ControlPanel.java

/**
 * Initializes the frame menu./* w  ww .ja  v a  2  s .c om*/
 */
private void initializeMenu() {
    Menu menu;
    MenuItem item;

    // Create file menu
    if (!SystemUtils.IS_OS_MAC_OSX) {
        menu = new Menu("File");
        item = new MenuItem("Exit", new MenuShortcut(KeyEvent.VK_Q));
        item.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                quit();
            }
        });
        menu.add(item);
        menuBar.add(menu);
        menu = new Menu("Help");
        item = new MenuItem("About");
        item.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                about();
            }
        });
        menu.add(item);
        menuBar.add(menu);
    }

    // Fix Mac OS specific menus
    if (SystemUtils.IS_OS_MAC_OSX) {
        try {
            MacApplication.get().setAboutHandler(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    about();
                }
            });
            MacApplication.get().setPreferencesHandler(null);
        } catch (Exception ignore) {
            // Errors are ignored
        }
    }
}