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:com.mirth.connect.client.ui.editors.transformer.TransformerPane.java

/**
 * This method is called from within the constructor to initialize the form.
 *//*from  w  ww  .  jav  a  2 s  . c  o m*/
public void initComponents() {

    // the available panels (cards)
    stepPanel = new BasePanel();
    blankPanel = new BasePanel();

    scriptTextArea = new MirthRTextScrollPane(null, true, SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT, false);
    scriptTextArea.setBackground(new Color(204, 204, 204));
    scriptTextArea.setBorder(BorderFactory.createEtchedBorder());
    scriptTextArea.getTextArea().setEditable(false);
    scriptTextArea.getTextArea().setDropTarget(null);

    generatedScriptPanel = new JPanel();
    generatedScriptPanel.setBackground(Color.white);
    generatedScriptPanel.setLayout(new CardLayout());
    generatedScriptPanel.add(scriptTextArea, "");

    tabbedPane = new JTabbedPane();
    tabbedPane.addTab("Step", stepPanel);

    tabbedPane.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            switchTab = (lastSelectedIndex == 0 && tabbedPane.getSelectedIndex() == 1) ? true : false;
            updateCodePanel(null);
        }
    });

    for (TransformerStepPlugin transformerStepPlugin : LoadedExtensions.getInstance()
            .getTransformerStepPlugins().values()) {
        transformerStepPlugin.initialize(this);
    }

    // establish the cards to use in the Transformer
    stepPanel.addCard(blankPanel, BLANK_TYPE);
    for (TransformerStepPlugin plugin : LoadedExtensions.getInstance().getTransformerStepPlugins().values()) {
        stepPanel.addCard(plugin.getPanel(), plugin.getPluginPointName());
    }
    transformerTablePane = new JScrollPane();
    transformerTablePane.setBorder(BorderFactory.createEmptyBorder());

    viewTasks = new JXTaskPane();
    viewTasks.setTitle("Mirth Views");
    viewTasks.setFocusable(false);
    viewTasks.add(initActionCallback("accept", "Return back to channel.",
            ActionFactory.createBoundAction("accept", "Back to Channel", "B"),
            new ImageIcon(Frame.class.getResource("images/resultset_previous.png"))));
    parent.setNonFocusable(viewTasks);
    viewTasks.setVisible(false);
    parent.taskPaneContainer.add(viewTasks, parent.taskPaneContainer.getComponentCount() - 1);

    transformerTasks = new JXTaskPane();
    transformerTasks.setTitle("Transformer Tasks");
    transformerTasks.setFocusable(false);

    transformerPopupMenu = new JPopupMenu();

    // add new step task
    transformerTasks.add(initActionCallback("addNewStep", "Add a new transformer step.",
            ActionFactory.createBoundAction("addNewStep", "Add New Step", "N"),
            new ImageIcon(Frame.class.getResource("images/add.png"))));
    JMenuItem addNewStep = new JMenuItem("Add New Step");
    addNewStep.setIcon(new ImageIcon(Frame.class.getResource("images/add.png")));
    addNewStep.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            addNewStep();
        }
    });
    transformerPopupMenu.add(addNewStep);

    // delete step task
    transformerTasks.add(initActionCallback("deleteStep", "Delete the currently selected transformer step.",
            ActionFactory.createBoundAction("deleteStep", "Delete Step", "X"),
            new ImageIcon(Frame.class.getResource("images/delete.png"))));
    JMenuItem deleteStep = new JMenuItem("Delete Step");
    deleteStep.setIcon(new ImageIcon(Frame.class.getResource("images/delete.png")));
    deleteStep.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            deleteStep();
        }
    });
    transformerPopupMenu.add(deleteStep);

    transformerTasks.add(initActionCallback("doImport", "Import a transformer from an XML file.",
            ActionFactory.createBoundAction("doImport", "Import Transformer", "I"),
            new ImageIcon(Frame.class.getResource("images/report_go.png"))));
    JMenuItem importTransformer = new JMenuItem("Import Transformer");
    importTransformer.setIcon(new ImageIcon(Frame.class.getResource("images/report_go.png")));
    importTransformer.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            doImport();
        }
    });
    transformerPopupMenu.add(importTransformer);

    transformerTasks.add(initActionCallback("doExport", "Export the transformer to an XML file.",
            ActionFactory.createBoundAction("doExport", "Export Transformer", "E"),
            new ImageIcon(Frame.class.getResource("images/report_disk.png"))));
    JMenuItem exportTransformer = new JMenuItem("Export Transformer");
    exportTransformer.setIcon(new ImageIcon(Frame.class.getResource("images/report_disk.png")));
    exportTransformer.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            doExport();
        }
    });
    transformerPopupMenu.add(exportTransformer);

    transformerTasks.add(initActionCallback("doValidate", "Validate the currently viewed script.",
            ActionFactory.createBoundAction("doValidate", "Validate Script", "V"),
            new ImageIcon(Frame.class.getResource("images/accept.png"))));
    JMenuItem validateStep = new JMenuItem("Validate Script");
    validateStep.setIcon(new ImageIcon(Frame.class.getResource("images/accept.png")));
    validateStep.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            doValidate();
        }
    });
    transformerPopupMenu.add(validateStep);

    // move step up task
    transformerTasks.add(initActionCallback("moveStepUp", "Move the currently selected step up.",
            ActionFactory.createBoundAction("moveStepUp", "Move Step Up", "P"),
            new ImageIcon(Frame.class.getResource("images/arrow_up.png"))));
    JMenuItem moveStepUp = new JMenuItem("Move Step Up");
    moveStepUp.setIcon(new ImageIcon(Frame.class.getResource("images/arrow_up.png")));
    moveStepUp.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            moveStepUp();
        }
    });
    transformerPopupMenu.add(moveStepUp);

    // move step down task
    transformerTasks.add(initActionCallback("moveStepDown", "Move the currently selected step down.",
            ActionFactory.createBoundAction("moveStepDown", "Move Step Down", "D"),
            new ImageIcon(Frame.class.getResource("images/arrow_down.png"))));
    JMenuItem moveStepDown = new JMenuItem("Move Step Down");
    moveStepDown.setIcon(new ImageIcon(Frame.class.getResource("images/arrow_down.png")));
    moveStepDown.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            moveStepDown();
        }
    });
    transformerPopupMenu.add(moveStepDown);

    // add the tasks to the taskpane, and the taskpane to the mirth client
    parent.setNonFocusable(transformerTasks);
    transformerTasks.setVisible(false);
    parent.taskPaneContainer.add(transformerTasks, parent.taskPaneContainer.getComponentCount() - 1);

    makeTransformerTable();

    // BGN LAYOUT
    transformerTable.setBorder(BorderFactory.createEmptyBorder());
    transformerTablePane.setBorder(BorderFactory.createEmptyBorder());
    transformerTablePane.setMinimumSize(new Dimension(0, 40));
    stepPanel.setBorder(BorderFactory.createEmptyBorder());

    hSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, transformerTablePane, tabbedPane);
    hSplitPane.setContinuousLayout(true);
    // hSplitPane.setDividerSize(6);
    hSplitPane.setOneTouchExpandable(true);
    vSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, hSplitPane, refPanel);
    // vSplitPane.setDividerSize(6);
    vSplitPane.setOneTouchExpandable(true);
    vSplitPane.setContinuousLayout(true);

    hSplitPane.setBorder(BorderFactory.createEmptyBorder());
    vSplitPane.setBorder(BorderFactory.createEmptyBorder());
    this.setLayout(new BorderLayout());
    this.add(vSplitPane, BorderLayout.CENTER);
    setBorder(BorderFactory.createEmptyBorder());
    resizePanes();
    // END LAYOUT

}

From source file:org.biojava.bio.view.MotifAnalyzer.java

/**
 * This method initializes jJMenuBar   //from  www  . j a  va 2 s.  c  o  m
 *    
 * @return javax.swing.JMenuBar   
 */
private JMenuBar getJJMenuBar() {
    if (jJMenuBar == null) {
        jJMenuBar = new JMenuBar();
        jJMenuBar.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
    }
    /* File Menu */
    JMenu fileMenu = new JMenu("File");
    fileMenu.setFont(menuFont);
    jJMenuBar.add(fileMenu);

    JMenuItem loadItem = new JMenuItem(loadMenuName);
    loadItem.addActionListener(this);
    fileMenu.add(loadItem);

    JMenuItem saveItem = new JMenuItem(saveMenuName);
    saveItem.addActionListener(this);
    fileMenu.add(saveItem);

    JMenuItem openMotifVoterItem = new JMenuItem(convertMotifVoterMenuName);
    openMotifVoterItem.addActionListener(this);
    fileMenu.add(openMotifVoterItem);

    JMenuItem runPatchConverMVItem = new JMenuItem(runPatchConverMVMenuName);
    runPatchConverMVItem.addActionListener(this);
    fileMenu.add(runPatchConverMVItem);

    JMenuItem convertAllItem = new JMenuItem(convertAllMenuName);
    convertAllItem.addActionListener(this);
    fileMenu.add(convertAllItem);

    JMenuItem runPatchConverAllItem = new JMenuItem(runPatchConverAllMenuName);
    runPatchConverAllItem.addActionListener(this);
    fileMenu.add(runPatchConverAllItem);

    JMenuItem compareSetsItem = new JMenuItem(compareSetsName);
    compareSetsItem.addActionListener(this);
    fileMenu.add(compareSetsItem);

    JMenuItem mergeCompareSetsItem = new JMenuItem(mergeCompareSetsName);
    mergeCompareSetsItem.addActionListener(this);
    fileMenu.add(mergeCompareSetsItem);

    JMenuItem copyFilesWithExtensionItem = new JMenuItem(copyCleanInputFilesName);
    copyFilesWithExtensionItem.addActionListener(this);
    fileMenu.add(copyFilesWithExtensionItem);

    JMenuItem exitItem = new JMenuItem("Exit");
    exitItem.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            System.exit(0);
        }
    });
    fileMenu.add(exitItem);

    /* Tools Menu */
    JMenu toolsMenu = new JMenu("Tools");
    toolsMenu.setFont(menuFont);
    jJMenuBar.add(toolsMenu);

    JMenuItem gibbsItem = new JMenuItem(gibbsMenuName);
    gibbsItem.addActionListener(this);
    toolsMenu.add(gibbsItem);

    JMenuItem infoContentItem = new JMenuItem(infoContentMenuName);
    infoContentItem.addActionListener(this);
    toolsMenu.add(infoContentItem);

    JMenuItem removeRedundantSitesItem = new JMenuItem(removeRedundantSitesName);
    removeRedundantSitesItem.addActionListener(this);
    toolsMenu.add(removeRedundantSitesItem);

    JMenuItem extractSitesItem = new JMenuItem(extractSitesName);
    extractSitesItem.addActionListener(this);
    toolsMenu.add(extractSitesItem);

    JMenuItem drawKDistanceGraphItem = new JMenuItem(drawKDistanceGraphName);
    drawKDistanceGraphItem.addActionListener(this);
    toolsMenu.add(drawKDistanceGraphItem);

    JMenuItem computeWeightItem = new JMenuItem(computeWeightName);
    computeWeightItem.addActionListener(this);
    toolsMenu.add(computeWeightItem);

    /* Run Methods Menu */
    JMenu methodMenu = new JMenu("Run Method");
    methodMenu.setFont(menuFont);
    jJMenuBar.add(methodMenu);

    /*
    JMenuItem bioProspectorItem = new JMenuItem(runBioProspectorName);
    bioProspectorItem.addActionListener(this);
    methodMenu.add(bioProspectorItem);
            
    JMenuItem KMeansItem = new JMenuItem(runKMeansName);
    KMeansItem.addActionListener(this);
    methodMenu.add(KMeansItem);
            
    JMenuItem DBScanItem = new JMenuItem(runDBScanName);
    DBScanItem.addActionListener(this);
    methodMenu.add(DBScanItem);
            
    JMenuItem OPTICSItem = new JMenuItem(runOPTICSName);
    OPTICSItem.addActionListener(this);
    methodMenu.add(OPTICSItem);
            
    JMenuItem motifVoteItem = new JMenuItem(runMotifVoterName);
    motifVoteItem.addActionListener(this);
    methodMenu.add(motifVoteItem);
            
    JMenuItem runCliqueItem = new JMenuItem(runCliqueName);
    runCliqueItem.addActionListener(this);
    methodMenu.add(runCliqueItem);
    */

    for (int i = 0; i < Method.values().length; i++) {
        JMenuItem item = new JMenuItem(Method.values()[i].name());
        item.addActionListener(this);
        methodMenu.add(item);
    }

    /* Run Analysis for Methods Menu */
    JMenu analysisMenu = new JMenu("Analysis");
    analysisMenu.setFont(menuFont);
    jJMenuBar.add(analysisMenu);

    JMenuItem evaluateTompaMotifEachItem = new JMenuItem(evaluateTompaMotifEachName);
    evaluateTompaMotifEachItem.addActionListener(this);
    analysisMenu.add(evaluateTompaMotifEachItem);

    JMenuItem evaluateTompaMotifItem = new JMenuItem(evaluateTompaMotifAccName);
    evaluateTompaMotifItem.addActionListener(this);
    analysisMenu.add(evaluateTompaMotifItem);

    JMenuItem evaluateTompaMotifTotalItem = new JMenuItem(evaluateTompaMotifTotalName);
    evaluateTompaMotifTotalItem.addActionListener(this);
    analysisMenu.add(evaluateTompaMotifTotalItem);

    JMenuItem evaluateMotifVoterItem = new JMenuItem(evaluateMotifVoterName);
    evaluateMotifVoterItem.addActionListener(this);
    analysisMenu.add(evaluateMotifVoterItem);

    JMenuItem evaluateMotifVoterTotalItem = new JMenuItem(evaluateMotifVoterTotalName);
    evaluateMotifVoterTotalItem.addActionListener(this);
    analysisMenu.add(evaluateMotifVoterTotalItem);

    JMenuItem evaluateMVDirFirstEleItem = new JMenuItem(evaluateMVDirFirstEleName);
    evaluateMVDirFirstEleItem.addActionListener(this);
    analysisMenu.add(evaluateMVDirFirstEleItem);

    JMenuItem evaluateMVDirMergedItem = new JMenuItem(evaluateMVDirMergedName);
    evaluateMVDirMergedItem.addActionListener(this);
    analysisMenu.add(evaluateMVDirMergedItem);

    JMenuItem compareMotifVoterFirstItem = new JMenuItem(compareMotifVoterFirstName);
    compareMotifVoterFirstItem.addActionListener(this);
    analysisMenu.add(compareMotifVoterFirstItem);

    JMenuItem compareMotifVoterAllItem = new JMenuItem(compareMotifVoterAllName);
    compareMotifVoterAllItem.addActionListener(this);
    analysisMenu.add(compareMotifVoterAllItem);

    JMenuItem EvaluateAllResultsItem = new JMenuItem(evaluateAllResultsName);
    EvaluateAllResultsItem.addActionListener(this);
    analysisMenu.add(EvaluateAllResultsItem);

    return jJMenuBar;
}

From source file:at.becast.youploader.gui.FrmMain.java

public void loadAccounts() {
    int i = 0;/*from   w  ww  .j a  v  a2 s . c o m*/
    HashMap<AccountType, Integer> accounts = accMng.load();
    for (Entry<AccountType, Integer> entry : accounts.entrySet()) {
        getCmbAccount().addItem(entry.getKey());
        AccListModel.addElement(entry.getKey());
        JMenuItem rdoBtn = new JMenuItem(entry.getKey().toString());
        if (entry.getValue() == 1) {
            rdoBtn.setSelected(true);
            getCmbAccount().setSelectedItem(entry.getKey());
        }
        rdoBtn.setActionCommand(entry.getKey().toString());
        rdoBtn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                editAccount(e.getActionCommand());
            }
        });
        _accounts.put(i, rdoBtn);
        mnuAcc.add(rdoBtn);
        i++;
    }
    if (!accounts.isEmpty()) {
        btnAddToQueue.setEnabled(true);
    }

}

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

/**
 * Adds the Context PopupMenu for the RecordSet.
 * @param roc the RolloverCommand btn to add the pop to
 *//*from   w ww  . ja va 2 s  .com*/
public void addPopMenu(final RolloverCommand roc, final PickList pickList) {
    if (roc.getLabelText() != null) {
        final JPopupMenu popupMenu = new JPopupMenu();

        JMenuItem delMenuItem = new JMenuItem(getResourceString("Delete"));
        if (!pickList.getIsSystem()) {
            delMenuItem.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent actionEvent) {
                    CommandDispatcher.dispatch(new CommandAction(SYSTEMSETUPTASK, DELETE_CMD_ACT, roc));
                }
            });
        } else {
            delMenuItem.setEnabled(false);
        }
        popupMenu.add(delMenuItem);

        JMenuItem viewMenuItem = new JMenuItem(getResourceString("EDIT"));
        viewMenuItem.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent actionEvent) {
                startEditor(edu.ku.brc.specify.datamodel.PickList.class, "name", roc.getName(), roc.getName(),
                        PICKLIST);
            }
        });
        popupMenu.add(viewMenuItem);

        MouseListener mouseListener = new MouseAdapter() {
            private boolean showIfPopupTrigger(MouseEvent mouseEvent) {
                if (roc.isEnabled() && mouseEvent.isPopupTrigger() && popupMenu.getComponentCount() > 0) {
                    popupMenu.show(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY());
                    return true;
                }
                return false;
            }

            @Override
            public void mousePressed(MouseEvent mouseEvent) {
                if (roc.isEnabled()) {
                    showIfPopupTrigger(mouseEvent);
                }
            }

            @Override
            public void mouseReleased(MouseEvent mouseEvent) {
                if (roc.isEnabled()) {
                    showIfPopupTrigger(mouseEvent);
                }
            }
        };
        roc.addMouseListener(mouseListener);
    }
}

From source file:com.net2plan.gui.utils.viewEditTopolTables.specificTables.AdvancedJTable_demand.java

public void doPopup(final MouseEvent e, final int row, final Object itemId) {
    JPopupMenu popup = new JPopupMenu();

    final ITableRowFilter rf = callback.getVisualizationState().getTableRowFilter();
    final List<Demand> demandRowsInTheTable = getVisibleElementsInTable();

    /* Add the popup menu option of the filters */
    final List<Demand> selectedDemands = (List<Demand>) (List<?>) getSelectedElements().getFirst();
    if (!selectedDemands.isEmpty()) {
        final JMenu submenuFilters = new JMenu("Filters");
        final JMenuItem filterKeepElementsAffectedThisLayer = new JMenuItem(
                "This layer: Keep elements associated to this demand traffic");
        final JMenuItem filterKeepElementsAffectedAllLayers = new JMenuItem(
                "All layers: Keep elements associated to this demand traffic");
        submenuFilters.add(filterKeepElementsAffectedThisLayer);
        if (callback.getDesign().getNumberOfLayers() > 1)
            submenuFilters.add(filterKeepElementsAffectedAllLayers);
        filterKeepElementsAffectedThisLayer.addActionListener(new ActionListener() {
            @Override/*  w w w  .  j a v a2s  . c o m*/
            public void actionPerformed(ActionEvent e) {
                if (selectedDemands.size() > 1)
                    throw new RuntimeException();
                TBFToFromCarriedTraffic filter = new TBFToFromCarriedTraffic(selectedDemands.get(0), true);
                callback.getVisualizationState().updateTableRowFilter(filter);
                callback.updateVisualizationJustTables();
            }
        });
        filterKeepElementsAffectedAllLayers.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                if (selectedDemands.size() > 1)
                    throw new RuntimeException();
                TBFToFromCarriedTraffic filter = new TBFToFromCarriedTraffic(selectedDemands.get(0), false);
                callback.getVisualizationState().updateTableRowFilter(filter);
                callback.updateVisualizationJustTables();
            }
        });
        popup.add(submenuFilters);
        popup.addSeparator();
    }

    if (callback.getVisualizationState().isNetPlanEditable()) {
        popup.add(getAddOption());
        for (JComponent item : getExtraAddOptions())
            popup.add(item);
    }

    if (!demandRowsInTheTable.isEmpty()) {
        if (callback.getVisualizationState().isNetPlanEditable()) {
            if (row != -1) {
                if (popup.getSubElements().length > 0)
                    popup.addSeparator();

                JMenuItem removeItem = new JMenuItem("Remove " + networkElementType);

                removeItem.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        NetPlan netPlan = callback.getDesign();

                        try {
                            final Demand demand = netPlan.getDemandFromId((long) itemId);
                            demand.remove();
                            callback.getVisualizationState().resetPickedState();
                            callback.updateVisualizationAfterChanges(
                                    Collections.singleton(NetworkElementType.DEMAND));
                            callback.getUndoRedoNavigationManager().addNetPlanChange();
                        } catch (Throwable ex) {
                            ErrorHandling.addErrorOrException(ex, getClass());
                            ErrorHandling.showErrorDialog("Unable to remove " + networkElementType);
                        }
                    }
                });

                popup.add(removeItem);

                addPopupMenuAttributeOptions(e, row, itemId, popup);
            }

            JMenuItem removeItems = new JMenuItem("Remove all " + networkElementType + "s in the table");
            removeItems.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    NetPlan netPlan = callback.getDesign();

                    try {
                        if (rf == null)
                            netPlan.removeAllDemands();
                        else
                            for (Demand d : demandRowsInTheTable)
                                d.remove();

                        callback.getVisualizationState().resetPickedState();
                        callback.updateVisualizationAfterChanges(
                                Collections.singleton(NetworkElementType.DEMAND));
                        callback.getUndoRedoNavigationManager().addNetPlanChange();
                    } catch (Throwable ex) {
                        ex.printStackTrace();
                        ErrorHandling.showErrorDialog(ex.getMessage(),
                                "Unable to remove all " + networkElementType + "s");
                    }
                }
            });

            popup.add(removeItems);

            List<JComponent> extraOptions = getExtraOptions(row, itemId);
            if (!extraOptions.isEmpty()) {
                if (popup.getSubElements().length > 0)
                    popup.addSeparator();
                for (JComponent item : extraOptions)
                    popup.add(item);
            }
        }

        List<JComponent> forcedOptions = getForcedOptions();
        if (!forcedOptions.isEmpty()) {
            if (popup.getSubElements().length > 0)
                popup.addSeparator();
            for (JComponent item : forcedOptions)
                popup.add(item);
        }
    }

    popup.show(e.getComponent(), e.getX(), e.getY());
}

From source file:edu.ku.brc.specify.ui.containers.ContainerTreePanel.java

/**
 * @param actionTree//from w  w  w . j  ava2s. c o  m
 */
private void registerPrintContextMenu(final JTree actionTree) {
    actionTree.addMouseListener(new MouseAdapter() {
        private void displayMenu(MouseEvent e) {
            if (e.isPopupTrigger()) {
                JPopupMenu menu = new JPopupMenu();
                JMenuItem printMenu = new JMenuItem(UIRegistry.getResourceString("Print"));
                menu.add(printMenu);
                menu.show(e.getComponent(), e.getX(), e.getY());
                printMenu.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent ev) {
                        print(actionTree);
                    }
                });
            }
        }

        @Override
        public void mouseClicked(MouseEvent e) {
            super.mouseClicked(e);
            displayMenu(e);
        }

        @Override
        public void mousePressed(MouseEvent e) {
            super.mousePressed(e);
            displayMenu(e);
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            super.mouseReleased(e);
            displayMenu(e);
        }

    });
}

From source file:at.becast.youploader.gui.FrmMain.java

public void initMenuBar() {
    JMenuBar mnuBar = new JMenuBar();
    JMenu mnuFile = new JMenu();
    JMenuItem mnuQuit = new JMenuItem();
    mnuAcc = new JMenu();

    mnuFile.setText(LANG.getString("frmMain.menu.File"));

    mnuQuit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, InputEvent.ALT_MASK));
    mnuQuit.setText(LANG.getString("frmMain.menu.Quit"));
    mnuQuit.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            mnuQuitActionPerformed();/*from   ww w.ja va 2  s .com*/
        }
    });
    mnuFile.add(mnuQuit);

    mnuBar.add(mnuFile);

    mnuAcc.setText(LANG.getString("frmMain.menu.Account"));
    mnuBar.add(mnuAcc);

    JSeparator separator = new JSeparator();
    JMenuItem mntmAddAccount = new JMenuItem(LANG.getString("frmMain.menu.AddAccount"));
    mntmAddAccount.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            mntmAddAccountActionPerformed();
        }
    });
    mnuAcc.add(mntmAddAccount);
    mnuAcc.add(separator);

    JMenu mnLanguage = new JMenu("Language");
    mnLanguage.setVisible(false);
    mnLanguage.setEnabled(false);
    mnuBar.add(mnLanguage);

    JMenu menu = new JMenu("?");
    mnuBar.add(menu);

    JMenuItem mntmDonate = new JMenuItem(LANG.getString("frmMain.menu.Donate"));
    menu.add(mntmDonate);
    mntmDonate.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            donateButton();
        }
    });

    JMenuItem mntmAbout = new JMenuItem(LANG.getString("frmMain.menu.About"));
    mntmAbout.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            FrmAbout about = new FrmAbout();
            about.setVisible(true);
        }
    });
    menu.add(mntmAbout);

    JMenuItem mntmShowLogfile = new JMenuItem(LANG.getString("frmMain.menu.ShowLogfile"));
    mntmShowLogfile.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            DesktopUtil.openDir(new File(System.getProperty("user.home") + "/YouPloader"));
        }
    });
    menu.add(mntmShowLogfile);

    JMenuItem mntmUploadLogfile = new JMenuItem(LANG.getString("frmMain.menu.UploadLatestLogfile"));
    mntmUploadLogfile.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            DesktopUtil.openDir(new File(System.getProperty("user.home") + "/YouPloader"));
        }
    });
    menu.add(mntmUploadLogfile);

    chckbxmntmCheckForUpdates = new JCheckBoxMenuItem(LANG.getString("frmMain.menu.CheckforUpdates"));
    menu.add(chckbxmntmCheckForUpdates);
    if (Main.s.setting.get("notify_updates").equals("1")) {
        chckbxmntmCheckForUpdates.setSelected(true);
    }
    chckbxmntmCheckForUpdates.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            toggleUpdateNotifier();
        }
    });
    setJMenuBar(mnuBar);
}

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

private JMenuItem addLookAndFeel(final LookAndFeelInfo info) {
    if (info.getClassName().equals(SKINNABLE_LAF_CLASS_NAME)) {
        return getSkinnableLookAndFeelMenu(info);
    }//from   www. j a  va 2s  . com

    JMenuItem item = new JMenuItem(info.getName());
    item.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            changeLookAndFeel(info.getClassName(), null);
        }
    });

    return item;
}

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

private JMenuItem getThemePackItem(final LookAndFeelInfo info, final File pack) {
    JMenuItem item = new JMenuItem(getPackName(pack));

    item.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            changeLookAndFeel(info.getClassName(), pack.getAbsolutePath());
        }//from   w w  w  .  j  a v  a2 s  .  c o  m
    });

    return item;
}

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

private JMenuItem getConnectorGuiItem() {
    JMenuItem item = new JMenuItem("Show Connector GUI");

    item.addActionListener(new ActionListener() {

        @Override/* w ww .j  a va 2s .co m*/
        public void actionPerformed(ActionEvent arg0) {
            showConnectorGui();
        }
    });

    item.setToolTipText("Show the Connector GUI, allowing sending and receiving of Entrainer state messages");

    return item;
}