Example usage for javax.swing JMenu addMenuListener

List of usage examples for javax.swing JMenu addMenuListener

Introduction

In this page you can find the example usage for javax.swing JMenu addMenuListener.

Prototype

public void addMenuListener(MenuListener l) 

Source Link

Document

Adds a listener for menu events.

Usage

From source file:ContructMenuWithAction.java

public static void main(final String args[]) {
    JFrame frame = new JFrame("MenuSample Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JMenuBar menuBar = new JMenuBar();

    // File Menu, F - Mnemonic
    JMenu fileMenu = new JMenu("File");
    fileMenu.setMnemonic(KeyEvent.VK_F);
    menuBar.add(fileMenu);/*from  w  w w  . j a  v  a  2 s.com*/

    fileMenu.addMenuListener(new MenuListener() {

        public void menuSelected(MenuEvent e) {
            System.out.println("menuSelected");
        }

        public void menuDeselected(MenuEvent e) {
            System.out.println("menuDeselected");

        }

        public void menuCanceled(MenuEvent e) {
            System.out.println("menuCanceled");

        }
    });

    // File->New, N - Mnemonic
    JMenuItem newMenuItem = new JMenuItem("New");
    fileMenu.add(newMenuItem);

    frame.setJMenuBar(menuBar);
    frame.setSize(350, 250);
    frame.setVisible(true);
}

From source file:MenuX.java

public static void main(String args[]) {
    ActionListener actionListener = new MenuActionListener();
    MenuKeyListener menuKeyListener = new MyMenuKeyListener();
    ChangeListener cListener = new MyChangeListener();
    MenuListener menuListener = new MyMenuListener();
    MenuSelectionManager manager = MenuSelectionManager.defaultManager();
    manager.addChangeListener(cListener);
    JFrame frame = new JFrame("MenuSample Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JMenuBar bar = new VerticalMenuBar();
    //    JMenuBar bar = new JMenuBar();

    // File Menu, F - Mnemonic
    JMenu file = new JMenu("File");
    file.setMnemonic(KeyEvent.VK_F);
    file.addChangeListener(cListener);/*from ww w  .j a  va  2s  .c  o m*/
    file.addMenuListener(menuListener);
    file.addMenuKeyListener(menuKeyListener);
    JPopupMenu popupMenu = file.getPopupMenu();
    popupMenu.setLayout(new GridLayout(3, 3));
    bar.add(file);

    // File->New, N - Mnemonic
    JMenuItem newItem = new JMenuItem("New", KeyEvent.VK_N);
    newItem.addActionListener(actionListener);
    newItem.addChangeListener(cListener);
    newItem.addMenuKeyListener(menuKeyListener);
    file.add(newItem);

    // File->Open, O - Mnemonic
    JMenuItem openItem = new JMenuItem("Open", KeyEvent.VK_O);
    openItem.addActionListener(actionListener);
    openItem.addChangeListener(cListener);
    openItem.addMenuKeyListener(menuKeyListener);
    file.add(openItem);

    // File->Close, C - Mnemonic
    JMenuItem closeItem = new JMenuItem("Close", KeyEvent.VK_C);
    closeItem.addActionListener(actionListener);
    closeItem.addChangeListener(cListener);
    closeItem.addMenuKeyListener(menuKeyListener);
    file.add(closeItem);

    // Separator
    file.addSeparator();

    // File->Save, S - Mnemonic
    JMenuItem saveItem = new JMenuItem("Save", KeyEvent.VK_S);
    saveItem.addActionListener(actionListener);
    saveItem.addChangeListener(cListener);
    saveItem.addMenuKeyListener(menuKeyListener);
    file.add(saveItem);

    // Separator
    file.addSeparator();

    // File->Exit, X - Mnemonic
    JMenuItem exitItem = new JMenuItem("Exit", KeyEvent.VK_X);
    exitItem.addActionListener(actionListener);
    exitItem.addChangeListener(cListener);
    exitItem.addMenuKeyListener(menuKeyListener);
    file.add(exitItem);

    // Edit Menu, E - Mnemonic
    JMenu edit = new JMenu("Edit");
    edit.setMnemonic(KeyEvent.VK_E);
    edit.addChangeListener(cListener);
    edit.addMenuListener(menuListener);
    edit.addMenuKeyListener(menuKeyListener);
    bar.add(edit);

    // Edit->Cut, T - Mnemonic, CTRL-X - Accelerator
    JMenuItem cutItem = new JMenuItem("Cut", KeyEvent.VK_T);
    cutItem.addActionListener(actionListener);
    cutItem.addChangeListener(cListener);
    cutItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, Event.CTRL_MASK));
    cutItem.addMenuKeyListener(menuKeyListener);
    edit.add(cutItem);

    // Edit->Copy, C - Mnemonic, CTRL-C - Accelerator
    JMenuItem copyItem = new JMenuItem("Copy", KeyEvent.VK_C);
    copyItem.addActionListener(actionListener);
    copyItem.addChangeListener(cListener);
    copyItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, Event.CTRL_MASK));
    copyItem.addMenuKeyListener(menuKeyListener);
    copyItem.setEnabled(false);
    edit.add(copyItem);

    // Edit->Paste, P - Mnemonic, CTRL-V - Accelerator, Disabled
    JMenuItem pasteItem = new JMenuItem("Paste", KeyEvent.VK_P);
    pasteItem.addActionListener(actionListener);
    pasteItem.addChangeListener(cListener);
    pasteItem.addMenuKeyListener(menuKeyListener);
    pasteItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, Event.CTRL_MASK));
    pasteItem.setEnabled(false);
    edit.add(pasteItem);

    // Separator
    edit.addSeparator();

    // Edit->Find, F - Mnemonic, F3 - Accelerator
    JMenuItem findItem = new JMenuItem("Find", KeyEvent.VK_F);
    findItem.addActionListener(actionListener);
    findItem.addChangeListener(cListener);
    findItem.addMenuKeyListener(menuKeyListener);
    findItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0));
    edit.add(findItem);

    // Edit->Options Submenu, O - Mnemonic, at.gif - Icon Image File
    JMenu findOptions = new JMenu("Options");
    findOptions.addChangeListener(cListener);
    findOptions.addMenuListener(menuListener);
    findOptions.addMenuKeyListener(menuKeyListener);
    Icon atIcon = new ImageIcon("at.gif");
    findOptions.setIcon(atIcon);
    findOptions.setMnemonic(KeyEvent.VK_O);

    // ButtonGrou for radio buttons
    ButtonGroup directionGroup = new ButtonGroup();

    // Edit->Options->Forward, F - Mnemonic, in group
    JRadioButtonMenuItem forward = new JRadioButtonMenuItem("Forward", true);
    forward.addActionListener(actionListener);
    forward.addChangeListener(cListener);
    forward.addMenuKeyListener(menuKeyListener);
    forward.setMnemonic(KeyEvent.VK_F);
    findOptions.add(forward);
    directionGroup.add(forward);

    // Edit->Options->Backward, B - Mnemonic, in group
    JRadioButtonMenuItem backward = new JRadioButtonMenuItem("Backward");
    backward.addActionListener(actionListener);
    backward.addChangeListener(cListener);
    backward.addMenuKeyListener(menuKeyListener);
    backward.setMnemonic(KeyEvent.VK_B);
    findOptions.add(backward);
    directionGroup.add(backward);

    // Separator
    findOptions.addSeparator();

    // Edit->Options->Case Sensitive, C - Mnemonic
    JCheckBoxMenuItem caseItem = new JCheckBoxMenuItem("Case Sensitive");
    caseItem.addActionListener(actionListener);
    caseItem.addChangeListener(cListener);
    caseItem.addMenuKeyListener(menuKeyListener);
    caseItem.setMnemonic(KeyEvent.VK_C);
    findOptions.add(caseItem);
    edit.add(findOptions);

    frame.setJMenuBar(bar);
    //    frame.getContentPane().add(bar, BorderLayout.EAST);
    frame.setSize(350, 250);
    frame.setVisible(true);
}

From source file:MenuY.java

public static void main(String args[]) {
    ActionListener actionListener = new MenuActionListener();
    MenuKeyListener menuKeyListener = new MyMenuKeyListener();
    ChangeListener cListener = new MyChangeListener();
    MenuListener menuListener = new MyMenuListener();
    MenuSelectionManager manager = MenuSelectionManager.defaultManager();
    manager.addChangeListener(cListener);
    JFrame frame = new JFrame("MenuSample Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JMenuBar bar = new VerticalMenuBar();
    //    JMenuBar bar = new JMenuBar();

    // File Menu, F - Mnemonic
    JMenu file = new JMenu("File");
    file.setMnemonic(KeyEvent.VK_F);
    file.addChangeListener(cListener);/* w  w w . j a  v  a  2 s. c o  m*/
    file.addMenuListener(menuListener);
    file.addMenuKeyListener(menuKeyListener);
    JPopupMenu popupMenu = file.getPopupMenu();
    popupMenu.setLayout(new GridLayout(3, 3));
    bar.add(file);

    // File->New, N - Mnemonic
    JMenuItem newItem = new JMenuItem("New", KeyEvent.VK_N);
    newItem.addActionListener(actionListener);
    newItem.addChangeListener(cListener);
    newItem.addMenuKeyListener(menuKeyListener);
    file.add(newItem);

    // File->Open, O - Mnemonic
    JMenuItem openItem = new JMenuItem("Open", KeyEvent.VK_O);
    openItem.addActionListener(actionListener);
    openItem.addChangeListener(cListener);
    openItem.addMenuKeyListener(menuKeyListener);
    file.add(openItem);

    // File->Close, C - Mnemonic
    JMenuItem closeItem = new JMenuItem("Close", KeyEvent.VK_C);
    closeItem.addActionListener(actionListener);
    closeItem.addChangeListener(cListener);
    closeItem.addMenuKeyListener(menuKeyListener);
    file.add(closeItem);

    // Separator
    file.addSeparator();

    // File->Save, S - Mnemonic
    JMenuItem saveItem = new JMenuItem("Save", KeyEvent.VK_S);
    saveItem.addActionListener(actionListener);
    saveItem.addChangeListener(cListener);
    saveItem.addMenuKeyListener(menuKeyListener);
    file.add(saveItem);

    // Separator
    file.addSeparator();

    // File->Exit, X - Mnemonic
    JMenuItem exitItem = new JMenuItem("Exit", KeyEvent.VK_X);
    exitItem.addActionListener(actionListener);
    exitItem.addChangeListener(cListener);
    exitItem.addMenuKeyListener(menuKeyListener);
    file.add(exitItem);

    // Edit Menu, E - Mnemonic
    JMenu edit = new JMenu("Edit");
    edit.setMnemonic(KeyEvent.VK_E);
    edit.addChangeListener(cListener);
    edit.addMenuListener(menuListener);
    edit.addMenuKeyListener(menuKeyListener);
    bar.add(edit);

    // Edit->Cut, T - Mnemonic, CTRL-X - Accelerator
    JMenuItem cutItem = new JMenuItem("Cut", KeyEvent.VK_T);
    cutItem.addActionListener(actionListener);
    cutItem.addChangeListener(cListener);
    cutItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, Event.CTRL_MASK));
    cutItem.addMenuKeyListener(menuKeyListener);
    edit.add(cutItem);

    // Edit->Copy, C - Mnemonic, CTRL-C - Accelerator
    JMenuItem copyItem = new JMenuItem("Copy", KeyEvent.VK_C);
    copyItem.addActionListener(actionListener);
    copyItem.addChangeListener(cListener);
    copyItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, Event.CTRL_MASK));
    copyItem.addMenuKeyListener(menuKeyListener);
    copyItem.setEnabled(false);
    edit.add(copyItem);

    // Edit->Paste, P - Mnemonic, CTRL-V - Accelerator, Disabled
    JMenuItem pasteItem = new JMenuItem("Paste", KeyEvent.VK_P);
    pasteItem.addActionListener(actionListener);
    pasteItem.addChangeListener(cListener);
    pasteItem.addMenuKeyListener(menuKeyListener);
    pasteItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, Event.CTRL_MASK));
    pasteItem.setEnabled(false);
    edit.add(pasteItem);

    // Separator
    edit.addSeparator();

    // Edit->Find, F - Mnemonic, F3 - Accelerator
    JMenuItem findItem = new JMenuItem("Find", KeyEvent.VK_F);
    findItem.addActionListener(actionListener);
    findItem.addChangeListener(cListener);
    findItem.addMenuKeyListener(menuKeyListener);
    findItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0));
    edit.add(findItem);

    // Edit->Options Submenu, O - Mnemonic, at.gif - Icon Image File
    Icon atIcon = new ImageIcon("at.gif");
    Action findAction = new AbstractAction("Options", atIcon) {
        ActionListener actionListener = new MenuActionListener();

        public void actionPerformed(ActionEvent e) {
            actionListener.actionPerformed(e);
        }
    };
    findAction.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_O));
    JMenuItem jMenuItem = new JMenuItem(findAction);

    JMenu findOptions = new JMenu(findAction);
    findOptions.addChangeListener(cListener);
    findOptions.addMenuListener(menuListener);
    findOptions.addMenuKeyListener(menuKeyListener);

    // ButtonGrou for radio buttons
    ButtonGroup directionGroup = new ButtonGroup();

    // Edit->Options->Forward, F - Mnemonic, in group
    JRadioButtonMenuItem forward = new JRadioButtonMenuItem("Forward", true);
    forward.addActionListener(actionListener);
    forward.addChangeListener(cListener);
    forward.addMenuKeyListener(menuKeyListener);
    forward.setMnemonic(KeyEvent.VK_F);
    findOptions.add(forward);
    directionGroup.add(forward);

    // Edit->Options->Backward, B - Mnemonic, in group
    JRadioButtonMenuItem backward = new JRadioButtonMenuItem("Backward");
    backward.addActionListener(actionListener);
    backward.addChangeListener(cListener);
    backward.addMenuKeyListener(menuKeyListener);
    backward.setMnemonic(KeyEvent.VK_B);
    findOptions.add(backward);
    directionGroup.add(backward);

    // Separator
    findOptions.addSeparator();

    // Edit->Options->Case Sensitive, C - Mnemonic
    JCheckBoxMenuItem caseItem = new JCheckBoxMenuItem("Case Sensitive");
    caseItem.addActionListener(actionListener);
    caseItem.addChangeListener(cListener);
    caseItem.addMenuKeyListener(menuKeyListener);
    caseItem.setMnemonic(KeyEvent.VK_C);
    findOptions.add(caseItem);
    edit.add(findOptions);

    frame.setJMenuBar(bar);
    //    frame.getContentPane().add(bar, BorderLayout.EAST);
    frame.setSize(350, 250);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(final String args[]) {
    JFrame frame = new JFrame("MenuSample Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JMenuBar menuBar = new JMenuBar();

    // File Menu, F - Mnemonic
    JMenu fileMenu = new JMenu("File");
    fileMenu.setMnemonic(KeyEvent.VK_F);
    menuBar.add(fileMenu);/*  w w w .ja v  a 2 s. com*/

    MenuListener lis = new MenuListener() {

        public void menuSelected(MenuEvent e) {
            System.out.println("menuSelected");
        }

        public void menuDeselected(MenuEvent e) {
            System.out.println("menuDeselected");

        }

        public void menuCanceled(MenuEvent e) {
            System.out.println("menuCanceled");

        }
    };

    fileMenu.addMenuListener(lis);

    // File->New, N - Mnemonic
    JMenuItem newMenuItem = new JMenuItem("New");
    fileMenu.add(newMenuItem);

    frame.setJMenuBar(menuBar);
    frame.setSize(350, 250);
    frame.setVisible(true);

    fileMenu.removeMenuListener(lis);
}

From source file:MenuTest.java

public MenuTest() {
    super();//from  ww  w .  jav  a 2s . c  o m

    MenuListener listener = new MenuListener() {
        public void menuCanceled(MenuEvent e) {
            dumpInfo("Canceled", e);
        }

        public void menuDeselected(MenuEvent e) {
            dumpInfo("Deselected", e);
        }

        public void menuSelected(MenuEvent e) {
            dumpInfo("Selected", e);
        }

        private void dumpInfo(String s, MenuEvent e) {
            JMenu menu = (JMenu) e.getSource();
            System.out.println(s + ": " + menu.getText());
        }
    };

    JMenu fileMenu = new JMenu("File");
    fileMenu.addMenuListener(listener);
    fileMenu.add(new JMenuItem("Open"));
    fileMenu.add(new JMenuItem("Close"));
    fileMenu.add(new JMenuItem("Exit"));
    JMenu helpMenu = new JMenu("Help");
    helpMenu.addMenuListener(listener);
    helpMenu.add(new JMenuItem("About MenuTest"));
    helpMenu.add(new JMenuItem("Class Hierarchy"));
    helpMenu.addSeparator();
    helpMenu.add(new JCheckBoxMenuItem("Balloon Help"));
    JMenu subMenu = new JMenu("Categories");
    subMenu.addMenuListener(listener);
    JRadioButtonMenuItem rb;
    ButtonGroup group = new ButtonGroup();
    subMenu.add(rb = new JRadioButtonMenuItem("A Little Help", true));
    group.add(rb);
    subMenu.add(rb = new JRadioButtonMenuItem("A Lot of Help"));
    group.add(rb);
    helpMenu.add(subMenu);
    JMenuBar mb = new JMenuBar();
    mb.add(fileMenu);
    mb.add(helpMenu);
    setJMenuBar(mb);
}

From source file:com.haulmont.cuba.desktop.sys.MenuBuilder.java

private void createMenuBarItem(JMenuBar menuBar, MenuItem item) {
    String caption = menuConfig.getItemCaption(item.getId());
    if (!item.getChildren().isEmpty() || item.isMenu()) {
        final JMenu jMenu = new JMenu(caption);
        jMenu.addMenuListener(new MenuListener() {
            @Override//from w ww.  j av a2 s.c o  m
            public void menuSelected(MenuEvent e) {
                jMenu.requestFocus();
            }

            @Override
            public void menuDeselected(MenuEvent e) {
            }

            @Override
            public void menuCanceled(MenuEvent e) {
            }
        });
        jMenu.setName(item.getId());
        menuBar.add(jMenu);
        createSubMenu(jMenu, item);
    } else {
        JMenuItem jMenuItem = new JMenuItem(caption);
        jMenuItem.setName(item.getId());
        //todo remove hardcoded border
        jMenuItem.setBorder(BorderFactory.createEmptyBorder(1, 4, 2, 4));
        assignShortcut(jMenuItem, item);
        jMenuItem.setMaximumSize(
                new Dimension(jMenuItem.getPreferredSize().width, jMenuItem.getMaximumSize().height));
        assignCommand(jMenuItem, item);
        menuBar.add(jMenuItem);
    }
}

From source file:ca.sqlpower.swingui.object.VariablesPanel.java

@SuppressWarnings("unchecked")
private void showVarsPicker() {
    final MultiValueMap namespaces = this.variableHelper.getNamespaces();

    List<String> sortedNames = new ArrayList<String>(namespaces.keySet().size());
    sortedNames.addAll(namespaces.keySet());
    Collections.sort(sortedNames, new Comparator<String>() {
        public int compare(String o1, String o2) {
            if (o1 == null) {
                return -1;
            }/*  w  w  w .  jav a2 s  . c o  m*/
            if (o2 == null) {
                return 1;
            }
            return o1.compareTo(o2);
        };
    });

    final JPopupMenu menu = new JPopupMenu();
    for (final String name : sortedNames) {
        final JMenu subMenu = new JMenu(name);
        menu.add(subMenu);
        subMenu.addMenuListener(new MenuListener() {
            private Timer timer;

            public void menuSelected(MenuEvent e) {

                subMenu.removeAll();
                subMenu.add(new PleaseWaitAction());

                ActionListener menuPopulator = new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        if (subMenu.isPopupMenuVisible()) {
                            subMenu.removeAll();
                            for (Object namespaceO : namespaces.getCollection(name)) {
                                String namespace = (String) namespaceO;
                                logger.debug("Resolving variables for namespace ".concat(namespace));
                                int nbItems = 0;
                                for (String key : variableHelper.keySet(namespace)) {
                                    subMenu.add(new InsertVariableAction(SPVariableHelper.getKey((String) key),
                                            (String) key));
                                    nbItems++;
                                }
                                if (nbItems == 0) {
                                    subMenu.add(new DummyAction());
                                    logger.debug("No variables found.");
                                }
                            }
                            subMenu.revalidate();
                            subMenu.getPopupMenu().pack();
                        }
                    }
                };
                timer = new Timer(700, menuPopulator);
                timer.setRepeats(false);
                timer.start();
            }

            public void menuDeselected(MenuEvent e) {
                timer.stop();
            }

            public void menuCanceled(MenuEvent e) {
                timer.stop();
            }
        });
    }

    menu.show(varNameText, 0, varNameText.getHeight());
}

From source file:gdt.jgui.entity.contact.JContactEditor.java

@Override
public JMenu getContextMenu() {
    final JMenu menu = new JMenu("Context");
    menu.addMenuListener(new MenuListener() {
        @Override/*from  ww  w  .  j a  v a2 s . c  om*/
        public void menuSelected(MenuEvent e) {
            //         System.out.println("EntityEditor:getConextMenu:menu selected");
            menu.removeAll();
            JMenuItem facetsItem = new JMenuItem("Facets");
            facetsItem.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    save();
                    JEntityFacetPanel erm = new JEntityFacetPanel();
                    String locator$ = erm.getLocator();
                    locator$ = Locator.append(locator$, Entigrator.ENTIHOME, entihome$);
                    locator$ = Locator.append(locator$, EntityHandler.ENTITY_KEY, entityKey$);
                    JConsoleHandler.execute(console, locator$);
                }
            });
            menu.add(facetsItem);

            JMenuItem digestItem = new JMenuItem("Digest");
            digestItem.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    save();
                    String locator$ = getLocator();
                    JEntityDigestDisplay edd = new JEntityDigestDisplay();
                    edd.instantiate(console, locator$);
                    String eddLocator$ = edd.getLocator();
                    eddLocator$ = Locator.append(eddLocator$, Entigrator.ENTIHOME, entihome$);
                    eddLocator$ = Locator.append(eddLocator$, EntityHandler.ENTITY_KEY, entityKey$);
                    JConsoleHandler.execute(console, eddLocator$);

                }
            });
            menu.add(digestItem);

            JMenuItem structureItem = new JMenuItem("Structure");
            structureItem.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    save();
                    String locator$ = getLocator();
                    JEntityStructurePanel esp = new JEntityStructurePanel();
                    esp.instantiate(console, locator$);
                    String espLocator$ = esp.getLocator();
                    espLocator$ = Locator.append(espLocator$, Entigrator.ENTIHOME, entihome$);
                    espLocator$ = Locator.append(espLocator$, EntityHandler.ENTITY_KEY, entityKey$);
                    JConsoleHandler.execute(console, espLocator$);

                }
            });
            menu.add(structureItem);
            menu.addSeparator();
            JMenuItem doneItem = new JMenuItem("Done");
            doneItem.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {

                    try {
                        Entigrator entigrator = console.getEntigrator(entihome$);
                        Sack contact = entigrator.getEntityAtKey(entityKey$);
                        String entityLabel$ = contact.getProperty("label");
                        String title$ = title.getText();
                        if (!entityLabel$.equals(title$)) {
                            contact = entigrator.ent_assignLabel(contact, title$);
                            contact = entigrator.ent_assignProperty(contact, "contact",
                                    contact.getProperty("label"));
                        }
                        contact = entigrator.ent_assignProperty(contact, "phone", phone.getText());
                        contact = entigrator.ent_assignProperty(contact, "email", email.getText());
                        if (requesterResponseLocator$ != null) {
                            byte[] ba = Base64.decodeBase64(requesterResponseLocator$);
                            String responseLocator$ = new String(ba, "UTF-8");
                            //                     System.out.println("TextEditor:done:response locator="+responseLocator$);
                            JConsoleHandler.execute(console, responseLocator$);
                        } else
                            console.back();
                    } catch (Exception ee) {
                        Logger.getLogger(JContactEditor.class.getName()).severe(ee.toString());
                    }

                }
            });
            menu.add(doneItem);

            JMenuItem cancelItem = new JMenuItem("Cancel");
            cancelItem.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    console.back();
                }
            });
            menu.add(cancelItem);
        }

        @Override
        public void menuDeselected(MenuEvent e) {
            // TODO Auto-generated method stub

        }

        @Override
        public void menuCanceled(MenuEvent e) {
            // TODO Auto-generated method stub

        }

    });
    return menu;
}

From source file:com.googlecode.bpmn_simulator.gui.BPMNSimulatorFrame.java

private JMenu createMenuExtra() {
    final JMenu menuExtra = new JMenu(Messages.getString("Menu.extra")); //$NON-NLS-1$

    final JMenuItem menuExtraOpenExternalEditor = new JMenuItem(Messages.getString("Menu.openExternal")); //$NON-NLS-1$
    menuExtraOpenExternalEditor.addActionListener(new ActionListener() {
        @Override//from   w w  w  .  j  av a2s . c om
        public void actionPerformed(final ActionEvent event) {
            showExternalEditor();
        }
    });
    menuExtra.add(menuExtraOpenExternalEditor);

    menuExtra.addMenuListener(new MenuListener() {
        @Override
        public void menuSelected(final MenuEvent e) {
            menuExtraOpenExternalEditor.setEnabled(isDefinitionOpen());
        }

        @Override
        public void menuDeselected(final MenuEvent e) {
        }

        @Override
        public void menuCanceled(final MenuEvent e) {
        }
    });

    return menuExtra;
}

From source file:ca.phon.app.project.ProjectWindow.java

@Override
public void setJMenuBar(JMenuBar menu) {
    super.setJMenuBar(menu);

    JMenu projectMenu = new JMenu("Project");

    int projectMenuIndex = -1;
    // get the edit menu and add view commands
    for (int i = 0; i < menu.getMenuCount(); i++) {
        JMenu currentBar = menu.getMenu(i);

        if (currentBar != null && currentBar.getText() != null && currentBar.getText().equals("Workspace")) {
            projectMenuIndex = i + 1;//ww  w.  java 2s .  co  m
        }
    }

    if (projectMenuIndex > 0) {
        menu.add(projectMenu, projectMenuIndex);
    }

    // refresh lists 
    final RefreshAction refreshItem = new RefreshAction(this);
    projectMenu.add(refreshItem);
    projectMenu.addSeparator();

    // create corpus item
    final NewCorpusAction newCorpusItem = new NewCorpusAction(this);
    projectMenu.add(newCorpusItem);

    //       create corpus item
    final NewSessionAction newSessionItem = new NewSessionAction(this);
    projectMenu.add(newSessionItem);

    projectMenu.addSeparator();

    final AnonymizeAction anonymizeParticipantInfoItem = new AnonymizeAction(this);
    projectMenu.add(anonymizeParticipantInfoItem);

    final CheckTranscriptionsAction repairItem = new CheckTranscriptionsAction(this);
    projectMenu.add(repairItem);

    // merge/split sessions
    final DeriveSessionAction deriveItem = new DeriveSessionAction(this);
    projectMenu.add(deriveItem);

    final JMenu teamMenu = new JMenu("Team");
    teamMenu.addMenuListener(new MenuListener() {

        @Override
        public void menuSelected(MenuEvent e) {
            teamMenu.removeAll();
            if (getProject() != null) {
                final ProjectGitController gitController = new ProjectGitController(getProject());
                if (gitController.hasGitFolder()) {
                    teamMenu.add(new CommitAction(ProjectWindow.this));

                    teamMenu.addSeparator();

                    teamMenu.add(new PullAction(ProjectWindow.this));
                    teamMenu.add(new PushAction(ProjectWindow.this));

                } else {
                    final InitAction initRepoAct = new InitAction(ProjectWindow.this);
                    teamMenu.add(initRepoAct);
                }
            }
        }

        @Override
        public void menuDeselected(MenuEvent e) {

        }

        @Override
        public void menuCanceled(MenuEvent e) {

        }
    });
    projectMenu.addSeparator();
    projectMenu.add(teamMenu);
}