Example usage for javax.swing JPopupMenu JPopupMenu

List of usage examples for javax.swing JPopupMenu JPopupMenu

Introduction

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

Prototype

public JPopupMenu() 

Source Link

Document

Constructs a JPopupMenu without an "invoker".

Usage

From source file:com.eviware.soapui.impl.wsdl.panels.teststeps.WsdlTestRequestDesktopPanel.java

protected SoapMessageXmlEditor buildRequestEditor() {
    SoapMessageXmlEditor editor = super.buildRequestEditor();

    XmlOutlineEditor outlineEditor = editor.getOutlineEditor();
    if (outlineEditor != null) {
        JPopupMenu popupMenu = new JPopupMenu();
        popupMenu.add(new TransferFromPropertyAction(getRequest(), outlineEditor));

        outlineEditor.getOutlineTable().setComponentPopupMenu(popupMenu);

        XmlSourceEditor sourceEditor = editor.getSourceEditor();
        if (sourceEditor != null) {
            JPopupMenu editorPopup = sourceEditor.getEditorPopup();
            editorPopup.insert(new TransferFromPropertyFromSource(getRequest(), sourceEditor, outlineEditor),
                    0);/*from   ww  w .  j  a  v  a2 s .  co m*/
        }
    }

    return editor;
}

From source file:userinterface.properties.GUIGraphHandler.java

public GUIGraphHandler(JFrame parent, GUIPlugin plug, boolean canDelete) {
    this.plug = plug;
    this.canDelete = canDelete;

    this.graphMenu = new JPopupMenu();
    this.backMenu = new JPopupMenu();

    initComponents();//ww  w . j  a v a 2  s .  c  o  m

    pngFilter = new FileNameExtensionFilter("PNG files (*.png)", "png");
    jpgFilter = new FileNameExtensionFilter("JPEG files (*.jpg, *.jpeg)", "jpg", "jpeg");
    pdfFilter = new FileNameExtensionFilter("PDF files(*.pdf)", "pdf");
    epsFilter = new FileNameExtensionFilter("Encapsulated PostScript files (*.eps)", "eps");
    graFilter = new FileNameExtensionFilter("PRISM graph files (*.gra, *.xml)", "gra", "xml");
    matlabFilter = new FileNameExtensionFilter("Matlab files (*.m)", "m");
    gnuplotFilter = new FileNameExtensionFilter("GNU plot files (*gnuplot , *.gplot , *.gp , *.plt , *.gpi)",
            "gnuplot");

    models = new ArrayList<JPanel>();
    options = new ArrayList<GraphOptions>();
}

From source file:com.sshtools.common.ui.SshToolsApplicationPanel.java

/**
 * Initialize the panel// ww w  .  jav  a 2  s . c  om
 *
 * @param application
 *
 * @throws SshToolsApplicationException
 */

public void init(SshToolsApplication application) throws

SshToolsApplicationException {

    this.application = application;

    menuBar = new JMenuBar();

    // Creat the tool bar

    toolBar = new JToolBar();

    toolBar.setFloatable(false);

    toolBar.setBorderPainted(false);

    toolBar.putClientProperty("JToolBar.isRollover", Boolean.TRUE);

    // Create the context menu

    contextMenu = new JPopupMenu();

    registerActionMenu(new ActionMenu("Tools", "Tools", 't', 30));

    if (PreferencesStore.isStoreAvailable()) {

        log.debug("Preferences store is available, adding options action");

        registerAction(new OptionsAction() {

            public void actionPerformed(ActionEvent evt) {

                showOptions();

            }

        });

    }

}

From source file:com.limegroup.gnutella.gui.library.LibraryTableMediator.java

protected JPopupMenu createPopupMenu() {
    if (TABLE.getSelectionModel().isSelectionEmpty())
        return null;

    JPopupMenu menu = new JPopupMenu();

    menu.add(new JMenuItem(LAUNCH_ACTION));
    menu.add(new JMenuItem(ENQUEUE_ACTION));
    menu.addSeparator();/* www  . j a  v  a2 s  .c  o  m*/
    menu.add(new JMenuItem(RESUME_ACTION));
    menu.addSeparator();
    menu.add(new JMenuItem(DELETE_ACTION));
    menu.add(new JMenuItem(RENAME_ACTION));
    menu.addSeparator();

    DataLine[] dls = TABLE.getSelectedDataLines();
    boolean dirSelected = false;
    boolean fileSelected = false;
    for (int i = 0; i < dls.length; i++) {
        if (((LibraryTableDataLine) dls[i]).getFile().isDirectory())
            dirSelected = true;
        else
            fileSelected = true;

        if (dirSelected && fileSelected)
            break;
    }
    if (dirSelected) {
        if (GUIMediator.isPlaylistVisible())
            ENQUEUE_ACTION.setEnabled(false);
        DELETE_ACTION.setEnabled(false);
        RENAME_ACTION.setEnabled(false);
        if (fileSelected) {
            JMenu sharingMenu = new JMenu(GUIMediator.getStringResource("LIBRARY_TABLE_SHARING_SUB_MENU"));
            sharingMenu.add(new JMenuItem(SHARE_ACTION));
            sharingMenu.add(new JMenuItem(UNSHARE_ACTION));
            sharingMenu.add(new JMenuItem(ANNOTATE_ACTION));
            sharingMenu.add(new JMenuItem(PUBLISH_ACTION));
            sharingMenu.addSeparator();
            sharingMenu.add(new JMenuItem(SHARE_FOLDER_ACTION));
            sharingMenu.add(new JMenuItem(UNSHARE_FOLDER_ACTION));
            menu.add(sharingMenu);
        } else {
            menu.add(new JMenuItem(SHARE_FOLDER_ACTION));
            menu.add(new JMenuItem(UNSHARE_FOLDER_ACTION));
        }
    } else {
        if (GUIMediator.isPlaylistVisible())
            ENQUEUE_ACTION.setEnabled(true);
        DELETE_ACTION.setEnabled(true);
        RENAME_ACTION.setEnabled(!_isIncomplete);
        menu.add(new JMenuItem(SHARE_ACTION));
        menu.add(new JMenuItem(UNSHARE_ACTION));
        menu.add(new JMenuItem(ANNOTATE_ACTION));
        menu.add(new JMenuItem(PUBLISH_ACTION));
    }
    menu.addSeparator();

    menu.add(createSearchSubMenu((LibraryTableDataLine) dls[0]));
    menu.add(createAdvancedMenu((LibraryTableDataLine) dls[0]));

    LICENSE_ACTION.setEnabled(dls != null && dls[0] != null && ((LibraryTableDataLine) dls[0]).isLicensed());

    return menu;
}

From source file:com.sshtools.appframework.api.ui.SshToolsApplicationPanel.java

/**
 * Initialize the panel//from w  ww. j  a v  a2  s. c  o m
 * 
 * @param application
 * 
 * @throws SshToolsApplicationException
 */
public void init(SshToolsApplication application) throws SshToolsApplicationException {
    this.application = application;
    menuBar = new JMenuBar();
    // Create the tool bar
    toolBar = new ActionToolBar();
    toolBar.setFloatable(false);
    toolBar.setBorderPainted(true);
    toolBar.putClientProperty("JToolBar.isRollover", Boolean.TRUE);
    // Create the context menu
    contextMenu = new JPopupMenu();
    registerActionMenu(new ActionMenu("Tools", "Tools", 't', 30));
    if (PreferencesStore.isStoreAvailable()) {
        if (optionsActionAvailable) {
            registerAction(new AbstractOptionsAction() {
                private static final long serialVersionUID = 1L;

                public void actionPerformed(ActionEvent evt) {
                    showOptions();
                }
            });
        }
    }
    actionBuilder = new SshToolsApplicationPanelActionBuilder(menuBar, toolBar, contextMenu);
}

From source file:com.github.dougkelly88.FLIMPlateReaderGUI.SequencingClasses.GUIComponents.XYSequencing.java

private void setControlDefaults() {

    pmdp_ = new PlateMapDrawPanel(this);
    sap_ = SeqAcqProps.getInstance();/* w  ww .  j a  v a  2  s  .c  o m*/
    plateMapBasePanel.setLayout(new BorderLayout());
    plateMapBasePanel.add(pmdp_, BorderLayout.CENTER);

    tableModel_ = new FOVTableModel(pp_);
    searchFOVtableModel_ = new FOVTableModel(pp_); //Not sure if this is the best way, but try it for now.
    tableModel_.addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent e) {

        }
    });

    fovTable_ = new JTable();
    fovTable_.setModel(tableModel_);
    fovTable_.setSurrendersFocusOnKeystroke(true);
    fovTable_.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);

    JScrollPane scroller = new javax.swing.JScrollPane(fovTable_);
    fovTable_.setPreferredScrollableViewportSize(new java.awt.Dimension(190, 130));
    fovTablePanel.setLayout(new BorderLayout());
    fovTablePanel.add(scroller, BorderLayout.CENTER);

    final JPopupMenu popupMenu = new JPopupMenu();
    JMenuItem deleteItem = new JMenuItem("Delete FOV");
    deleteItem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            int r = fovTable_.getSelectedRow();
            tableModel_.removeRow(r);
        }
    });
    JMenuItem addItem = new JMenuItem("Add FOV");
    addItem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            int r = fovTable_.getSelectedRow();
            tableModel_.insertRow(r, new FOV("A1", pp_, 6000));
        }
    });
    JMenuItem goToFOVItem = new JMenuItem("Go to FOV");
    goToFOVItem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            int r = fovTable_.getSelectedRow();
            //                FOV fov = tableModel_.getData().get(r);
            xyzmi_.gotoFOV(tableModel_.getData().get(r));
            if (!zAsOffset_) {
                double zval = tableModel_.getData().get(r).getZ();
                xyzmi_.moveZAbsolute(zval);
            } else {
                // obviously, this isn't quite right - we want to get
                // the offset of the CURRENT FOV (perhaps from parent in 
                // later implementations?) and subtract from that of the 
                // NEWLY SELECTED FOV. 
                // TODO: fix for proper zAsOffset behaviour. 
                // Wait for move completion
                while (xyzmi_.isStageBusy()) {
                    System.out.println("Stage moving...");
                }
                ;

                if (parent_.checkifAFenabled()) {
                    // If we have gone to the FOV, and have AF, do AF
                    xyzmi_.customAutofocus(parent_.getAFOffset());
                } else {
                    // If we don't have AF, go to the 'good offset position'
                    xyzmi_.moveZAbsolute(parent_.getFixedAFDefault());
                }
                //Now do the relative shift
                xyzmi_.moveZRelative(tableModel_.getData().get(r).getZ());
                System.out.println("Z value" + tableModel_.getData().get(r).getZ());
            }
        }
    });

    popupMenu.add(addItem);
    popupMenu.add(deleteItem);
    popupMenu.add(goToFOVItem);

    fovTable_.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {
            //                System.out.println("pressed");
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            if (e.isPopupTrigger()) {
                JTable source = (JTable) e.getSource();
                int row = source.rowAtPoint(e.getPoint());
                int column = source.columnAtPoint(e.getPoint());

                if (!source.isRowSelected(row)) {
                    source.changeSelection(row, column, false, false);
                }
                popupMenu.show(e.getComponent(), e.getX(), e.getY());
            }
        }
    });

    //        fovTable_.setDefaultRenderer(FOV.class, new TableRenderer());
    setupInsertComboBox();
}

From source file:net.sf.jabref.gui.PreviewPanel.java

private JPopupMenu createPopupMenu() {
    JPopupMenu menu = new JPopupMenu();
    menu.add(this.printAction);
    menu.add(this.copyPreviewAction);
    this.basePanel.ifPresent(p -> menu.add(p.frame().getSwitchPreviewAction()));
    return menu;//from   w  w w.  j a  va2  s  .c  o  m
}

From source file:com.eviware.soapui.impl.wsdl.panels.teststeps.WsdlTestRequestDesktopPanel.java

protected SoapMessageXmlEditor buildResponseEditor() {
    SoapMessageXmlEditor editor = super.buildResponseEditor();

    XmlOutlineEditor outlineEditor = editor.getOutlineEditor();
    if (outlineEditor != null) {
        JPopupMenu popupMenu = new JPopupMenu();
        popupMenu.add(new AddXPathContentAssertionAction(getRequest(), outlineEditor));
        popupMenu.add(new TransferToPropertyAction(getRequest(), outlineEditor));

        outlineEditor.getOutlineTable().setComponentPopupMenu(popupMenu);

        XmlSourceEditor sourceEditor = editor.getSourceEditor();
        if (sourceEditor != null) {
            JPopupMenu editorPopup = sourceEditor.getEditorPopup();
            editorPopup.insert(//from  ww  w.  j  a  v a 2s  . c  o  m
                    new AddXPathContentAssertionFromSource(getRequest(), sourceEditor, outlineEditor), 0);
            editorPopup.insert(new TransferToPropertyFromSource(getRequest(), sourceEditor, outlineEditor), 0);
        }
    }

    return editor;
}

From source file:de.tbuchloh.kiskis.gui.widgets.PasswordElement.java

private void initCreatePopup() {
    _pwdCreateMenu = new JPopupMenu();
    final JMenuItem secure = new JMenuItem(M.getString("secure_item")); //$NON-NLS-1$
    secure.addActionListener(new PasswordActionListener(PasswordFactory.SECURE));
    _pwdCreateMenu.add(secure);//from   w ww  .j  a v  a 2s.  c  o  m

    final JMenuItem human = new JMenuItem(M.getString("human_readable_item")); //$NON-NLS-1$
    human.addActionListener(new PasswordActionListener(PasswordFactory.HUMAN_READABLE));
    _pwdCreateMenu.add(human);

    final JMenuItem template = new JMenuItem(M.createAction(this, "onCreateByTemplate"));
    _pwdCreateMenu.add(template);

    _specialActionsMenu = new JPopupMenu();
    _specialActionsMenu.add(M.createAction(this, "onCopyToClipboard"));

    _pwdField.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(final MouseEvent e) {
            if (e.getButton() != MouseEvent.BUTTON3) {
                return;
            }
            final int x = e.getX(); // _pwdField.getWidth()
            // - _specialActionsMenu.getWidth();
            final int y = e.getY();

            LOG.debug("Show context menu x=" + x + ", y=" + y);
            _specialActionsMenu.show(_pwdField, x, y);
        }
    });
}

From source file:edu.harvard.mcz.imagecapture.DeterminationFrame.java

/**
 * This method initializes jTable   //from www. j ava  2  s.c  om
 *    
 * @return javax.swing.JTable   
 */
private JTable getJTable() {
    if (jTableDeterminations == null) {
        jTableDeterminations = new JTable();
        DeterminationTableModel model = new DeterminationTableModel();
        jTableDeterminations.setModel(model);
        if (determinations != null) {
            jTableDeterminations.setModel(determinations);
        }

        FilteringAgentJComboBox field = new FilteringAgentJComboBox();
        jTableDeterminations.getColumnModel().getColumn(DeterminationTableModel.ROW_IDENTIFIEDBY)
                .setCellEditor(new ComboBoxCellEditor(field));

        setTableColumnEditors();

        jTableDeterminations.setRowHeight(jTableDeterminations.getRowHeight() + 4);

        jTableDeterminations.addMouseListener(new MouseAdapter() {
            @Override
            public void mousePressed(MouseEvent e) {
                if (e.isPopupTrigger()) {
                    clickedOnDetsRow = ((JTable) e.getComponent()).getSelectedRow();
                    jPopupDets.show(e.getComponent(), e.getX(), e.getY());
                }
            }

            @Override
            public void mouseReleased(MouseEvent e) {
                if (e.isPopupTrigger()) {
                    clickedOnDetsRow = ((JTable) e.getComponent()).getSelectedRow();
                    jPopupDets.show(e.getComponent(), e.getX(), e.getY());
                }
            }
        });

        jPopupDets = new JPopupMenu();
        JMenuItem mntmDeleteRow = new JMenuItem("Delete Row");
        mntmDeleteRow.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                try {
                    log.debug(clickedOnDetsRow);
                    if (clickedOnDetsRow >= 0) {
                        int ok = JOptionPane.showConfirmDialog(thisFrame, "Delete the selected determination?",
                                "Delete Determination", JOptionPane.OK_CANCEL_OPTION);
                        if (ok == JOptionPane.OK_OPTION) {
                            log.debug("deleting determination row " + clickedOnDetsRow);
                            ((DeterminationTableModel) jTableDeterminations.getModel())
                                    .deleteRow(clickedOnDetsRow);
                        } else {
                            log.debug("determination row delete canceled by user.");
                        }
                    } else {
                        JOptionPane.showMessageDialog(thisFrame, "Unable to select row to delete.");
                    }
                } catch (Exception ex) {
                    log.error(ex.getMessage());
                    JOptionPane.showMessageDialog(thisFrame,
                            "Failed to delete a determination row. " + ex.getMessage());
                }
            }
        });
        jPopupDets.add(mntmDeleteRow);

    }
    return jTableDeterminations;
}