Example usage for javax.swing JMenuItem addActionListener

List of usage examples for javax.swing JMenuItem addActionListener

Introduction

In this page you can find the example usage for javax.swing JMenuItem addActionListener.

Prototype

public void addActionListener(ActionListener l) 

Source Link

Document

Adds an ActionListener to the button.

Usage

From source file:net.sourceforge.entrainer.gui.EntrainerFX.java

private JMenuItem getChangePortItem() {
    JMenuItem item = new JMenuItem("Choose Socket Host & Port");

    item.addActionListener(new ActionListener() {

        @Override//from w w w.  j  a  v  a2  s  . c o  m
        public void actionPerformed(ActionEvent arg0) {
            showSocketPortDialog();
        }
    });

    item.setToolTipText("Choose the host and port on which Entrainer sends and receives state messages");

    return item;
}

From source file:com.igormaznitsa.jhexed.swing.editor.ui.MainForm.java

private void readAndParsePluginScript(final Reader reader) throws IOException {
    final DelegatingScript script = (DelegatingScript) this.groovyShell.parse(reader);
    script.setDelegate(this.dsl);
    final String name = (String) script.invokeMethod("getPluginName", new Object[] {});
    final String description = (String) script.invokeMethod("getDescription", new Object[] {});
    final JMenuItem menuItem = new JMenuItem(name);
    menuItem.setToolTipText(description);
    menuItem.addActionListener(new ActionListener() {

        @Override//from   w ww. ja v  a2  s.  com
        public void actionPerformed(ActionEvent e) {
            try {
                if (selectedLayer != null) {
                    addedUndoStep(new HexFieldLayer[] { selectedLayer });
                }
                script.invokeMethod("doWork", new Object[] { selectedToolType, selectedLayer });
            } catch (Exception ex) {
                ex.printStackTrace();
                JOptionPane.showMessageDialog(rootPane, "Error during execution", "Script error",
                        JOptionPane.ERROR_MESSAGE);
            } finally {
                updateRedoUndoForCurrentLayer();
            }
            hexMapPanel.repaint();
        }
    });

    menuPlugins.add(menuItem);
}

From source file:edu.ku.brc.specify.tasks.DataEntryTask.java

@Override
public List<MenuItemDesc> getMenuItems() {
    String menuDesc = "Specify.DATA_MENU";

    menuItems = new Vector<MenuItemDesc>();

    if (permissions == null || permissions.canModify()) {
        String menuTitle = "DET_BTCH_REIDENT_MENU"; //$NON-NLS-1$
        String mneu = "DET_BTCH_REIDENT_MNEU"; //$NON-NLS-1$
        String desc = "DET_BTCH_REIDENT_DESC"; //$NON-NLS-1$
        JMenuItem mi = UIHelper.createLocalizedMenuItem(menuTitle, mneu, desc, true, null);
        mi.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                doBatchReidentify();/*from   w w w.j  av a2s .co  m*/
            }
        });
        MenuItemDesc rsMI = new MenuItemDesc(mi, menuDesc);
        rsMI.setPosition(MenuItemDesc.Position.After);
        menuItems.add(rsMI);
    }

    return menuItems;
}

From source file:net.sourceforge.entrainer.gui.EntrainerFX.java

private JMenuItem getExitItem() {
    JMenuItem exitItem = new JMenuItem("Exit");
    addMnemonic(exitItem, KeyEvent.VK_X);
    exitItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            exitPressed();/*from  w w w .j  a  v a2s  .  c o  m*/
        }
    });

    return exitItem;
}

From source file:net.sourceforge.entrainer.gui.EntrainerFX.java

private JMenuItem getStopItem() {
    JMenuItem stopItem = new JMenuItem("Stop");
    addMnemonic(stopItem, KeyEvent.VK_T);
    stopItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            soundControlPane.getStop().fire();
        }// www  .  jav  a 2  s.com
    });

    return stopItem;
}

From source file:net.sourceforge.entrainer.gui.EntrainerFX.java

private JMenuItem getStartItem() {
    JMenuItem startItem = new JMenuItem("Start");
    addMnemonic(startItem, KeyEvent.VK_S);
    startItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            soundControlPane.getPlay().fire();
        }//from   w  w  w  .j av a2 s  . c  o m
    });

    return startItem;
}

From source file:net.sourceforge.entrainer.gui.EntrainerFX.java

private JMenuItem getLicenseItem() {
    JMenuItem aboutItem = new JMenuItem("License");
    addMnemonic(aboutItem, KeyEvent.VK_I);
    aboutItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            License.showLicenseDialog();
        }//  w ww. j a  va2  s  .c om
    });

    return aboutItem;
}

From source file:net.sourceforge.entrainer.gui.EntrainerFX.java

private JMenuItem getRemoteDocItem() {
    JMenuItem item = new JMenuItem("Web Documentation");
    addMnemonic(item, KeyEvent.VK_W);
    item.addActionListener(new ActionListener() {

        @Override/*from   w  w  w.j  av a 2  s  .c o  m*/
        public void actionPerformed(ActionEvent arg0) {
            openBrowser("http://entrainer.sourceforge.net");
        }
    });

    return item;
}

From source file:net.sourceforge.entrainer.gui.EntrainerFX.java

private JMenuItem getLocalDocItem() {
    JMenuItem item = new JMenuItem("Local Documentation");
    addMnemonic(item, KeyEvent.VK_D);
    item.addActionListener(new ActionListener() {

        @Override/*from   w ww .j  a  v a  2s. c om*/
        public void actionPerformed(ActionEvent arg0) {
            openBrowser(getLocalDocAddress());
        }
    });

    return item;
}

From source file:net.sourceforge.entrainer.gui.EntrainerFX.java

private JMenuItem getEditXmlItem() {
    JMenuItem item = new JMenuItem("Edit Entrainer Program");
    addMnemonic(item, KeyEvent.VK_E);
    item.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            editXml();//w w w  . j  a  va2 s  .c  o  m
        }
    });

    return item;
}