Example usage for javax.swing JPopupMenu addSeparator

List of usage examples for javax.swing JPopupMenu addSeparator

Introduction

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

Prototype

public void addSeparator() 

Source Link

Document

Appends a new separator at the end of the menu.

Usage

From source file:com.frostwire.gui.library.LibraryDeviceTableMediator.java

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

    JPopupMenu menu = new SkinPopupMenu();

    menu.add(new SkinMenuItem(LAUNCH_ACTION));
    menu.add(new SkinMenuItem(saveToAction));

    int[] rows = TABLE.getSelectedRows();

    menu.addSeparator();
    LibraryDeviceTableDataLine line = DATA_MODEL.get(rows[0]);
    menu.add(createSearchSubMenu(line));

    return menu;/*from  w  w  w .j a va2  s . co m*/
}

From source file:gg.pistol.sweeper.gui.component.DecoratedPanel.java

/**
 * Helper method to add a contextual menu on a text component that will allow for Copy & Select All text actions.
 *///from   w  w  w .  ja v a2  s  .c o  m
protected void addCopyMenu(final JTextComponent component) {
    Preconditions.checkNotNull(component);

    if (!component.isEditable()) {
        component.setCursor(new Cursor(Cursor.TEXT_CURSOR));
    }

    final JPopupMenu contextMenu = new JPopupMenu();
    JMenuItem copy = new JMenuItem(component.getActionMap().get(DefaultEditorKit.copyAction));
    copy.setText(i18n.getString(I18n.TEXT_COPY_ID));
    contextMenu.add(copy);
    contextMenu.addSeparator();

    JMenuItem selectAll = new JMenuItem(component.getActionMap().get(DefaultEditorKit.selectAllAction));
    selectAll.setText(i18n.getString(I18n.TEXT_SELECT_ALL_ID));
    contextMenu.add(selectAll);

    component.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON3) {
                contextMenu.show(component, e.getX(), e.getY());
            }
        }
    });
}

From source file:com.eviware.soapui.support.log.JLogList.java

public JLogList(String title) {
    super(new BorderLayout());
    this.title = title;

    model = new LogListModel();
    logList = new JList(model);
    logList.setToolTipText(title);/*from   ww  w  .j  av a  2  s.c o  m*/
    logList.setCellRenderer(new LogAreaCellRenderer());
    logList.setPrototypeCellValue("Testing 123");
    logList.setFixedCellWidth(-1);

    JPopupMenu listPopup = new JPopupMenu();
    listPopup.add(new ClearAction());
    enableAction = new EnableAction();
    enableMenuItem = new JCheckBoxMenuItem(enableAction);
    enableMenuItem.setSelected(true);
    listPopup.add(enableMenuItem);
    listPopup.addSeparator();
    listPopup.add(new CopyAction());
    listPopup.add(new SetMaxRowsAction());
    listPopup.addSeparator();
    listPopup.add(new ExportToFileAction());

    logList.setComponentPopupMenu(listPopup);

    setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
    JScrollPane scrollPane = new JScrollPane(logList);
    UISupport.addPreviewCorner(scrollPane, true);
    add(scrollPane, BorderLayout.CENTER);

    requestAttributes = new SimpleAttributeSet();
    StyleConstants.setForeground(requestAttributes, Color.BLUE);

    responseAttributes = new SimpleAttributeSet();
    StyleConstants.setForeground(responseAttributes, Color.GREEN);

    try {
        maxRows = Long.parseLong(SoapUI.getSettings().getString("JLogList#" + title, "1000"));
    } catch (NumberFormatException e) {
    }
}

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

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

    if (callback.getVisualizationState().isNetPlanEditable()) {
        popup.add(getAddOption());//from   w w w  . j  a v a  2s  .  c  o m
        for (JComponent item : getExtraAddOptions())
            popup.add(item);
    }

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

                if (networkElementType == NetworkElementType.LAYER
                        && callback.getDesign().getNumberOfLayers() == 1) {

                } else {
                    JMenuItem removeItem = new JMenuItem("Remove " + networkElementType);

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

                            try {
                                netPlan.removeNetworkLayer(netPlan.getNetworkLayerFromId((long) itemId));

                                final VisualizationState vs = callback.getVisualizationState();
                                Pair<BidiMap<NetworkLayer, Integer>, Map<NetworkLayer, Boolean>> res = vs
                                        .suggestCanvasUpdatedVisualizationLayerInfoForNewDesign(
                                                new HashSet<>(callback.getDesign().getNetworkLayers()));
                                vs.setCanvasLayerVisibilityAndOrder(callback.getDesign(), res.getFirst(),
                                        res.getSecond());
                                callback.updateVisualizationAfterChanges(
                                        Sets.newHashSet(NetworkElementType.LAYER));
                                callback.getUndoRedoNavigationManager().addNetPlanChange();
                            } catch (Throwable ex) {
                                ErrorHandling.addErrorOrException(ex, getClass());
                                ErrorHandling.showErrorDialog("Unable to remove " + networkElementType);
                            }
                        }
                    });

                    popup.add(removeItem);
                }

                addPopupMenuAttributeOptions(e, row, itemId, popup);
            }
            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:org.eurocarbdb.application.glycoworkbench.plugin.AnnotationReportApplet.java

protected JPopupMenu createPopupMenu() {

    JPopupMenu menu = new JPopupMenu();

    menu.add(theActionManager.get("zoomnone"));
    menu.add(theActionManager.get("zoomin"));
    menu.add(theActionManager.get("zoomout"));

    menu.addSeparator();

    menu.add(theActionManager.get("cut"));
    menu.add(theActionManager.get("copy"));
    menu.add(theActionManager.get("delete"));

    menu.addSeparator();//from www  . j ava2  s  . c om

    menu.add(theActionManager.get("enlarge"));
    menu.add(theActionManager.get("resetsize"));
    menu.add(theActionManager.get("shrink"));

    menu.addSeparator();

    menu.add(theActionManager.get("group"));
    menu.add(theActionManager.get("ungroup"));

    return menu;
}

From source file:fi.elfcloud.client.tree.ClusterNode.java

private void populatePopupMenu(JPopupMenu menu, BeaverGUI gui) {
    JMenuItem item;//from  w w  w  .  j av  a  2s .c  o m
    item = new JMenuItem(Messages.getString("ClusterNode.popup_modify")); //$NON-NLS-1$
    item.setActionCommand(Integer.toString(gui.ACTION_MODIFY));
    item.addActionListener(gui);
    item.setIcon(new ImageIcon(BeaverGUI.class.getResource("icons/modify_rename16.png"))); //$NON-NLS-1$
    menu.add(item);

    item = new JMenuItem(Messages.getString("ClusterNode.popup_information")); //$NON-NLS-1$
    item.setIcon(new ImageIcon(BeaverGUI.class.getResource("icons/info_file16.png"))); //$NON-NLS-1$
    item.setActionCommand(Integer.toString(gui.ACTION_INFORMATION));
    item.addActionListener(gui);
    menu.add(item);
    menu.addSeparator();

    item = new JMenuItem(Messages.getString("ClusterNode.popup_delete")); //$NON-NLS-1$
    item.setActionCommand(Integer.toString(gui.ACTION_DELETE));
    item.addActionListener(gui);
    item.setIcon(new ImageIcon(BeaverGUI.class.getResource("icons/delete16.png"))); //$NON-NLS-1$
    menu.add(item);
}

From source file:net.sf.jhylafax.addressbook.AddressBook.java

private void initializeContent() {
    horizontalSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    horizontalSplitPane.setBorder(GUIHelper.createEmptyBorder(5));

    rootNode = new DefaultMutableTreeNode();
    addressBookTreeModel = new DefaultTreeModel(rootNode);
    addressBookTree = new JTree(addressBookTreeModel);
    addressBookTree.setRootVisible(false);
    addressBookTree.setCellRenderer(new ContactCollectionCellRenderer());
    horizontalSplitPane.add(new JScrollPane(addressBookTree));

    JPanel contactPanel = new JPanel();
    contactPanel.setLayout(new BorderLayout(0, 10));
    horizontalSplitPane.add(contactPanel);

    DefaultFormBuilder builder = new DefaultFormBuilder(
            new FormLayout("min, 3dlu, min, 3dlu, pref:grow, 3dlu, min", ""));
    contactPanel.add(builder.getPanel(), BorderLayout.NORTH);

    searchTextField = new JTextField(10);
    EraseTextFieldAction eraseAction = new EraseTextFieldAction(searchTextField) {
        public void actionPerformed(ActionEvent event) {
            super.actionPerformed(event);
            filterAction.actionPerformed(event);
        };//from   w w w  .j av  a 2s .c o  m
    };
    builder.append(new TabTitleButton(eraseAction));
    filterLabel = new JLabel();
    builder.append(filterLabel);
    builder.append(searchTextField);
    GUIHelper.bindEnterKey(searchTextField, filterAction);

    builder.append(Builder.createButton(filterAction));

    JPopupMenu tablePopupMenu = new JPopupMenu();
    tablePopupMenu.add(Builder.createMenuItem(newAction));
    tablePopupMenu.addSeparator();
    tablePopupMenu.add(Builder.createMenuItem(editAction));
    tablePopupMenu.addSeparator();
    tablePopupMenu.add(Builder.createMenuItem(deleteAction));

    contactTableModel = new AddressTableModel();
    TableSorter sorter = new TableSorter(contactTableModel);
    contactTable = new ColoredTable(sorter);
    contactTableLayoutManager = new TableLayoutManager(contactTable);
    contactTableLayoutManager.addColumnProperties("displayName", "", 180, true);
    contactTableLayoutManager.addColumnProperties("company", "", 80, true);
    contactTableLayoutManager.addColumnProperties("faxNumber", "", 60, true);
    contactTableLayoutManager.initializeTableLayout();
    contactPanel.add(new JScrollPane(contactTable), BorderLayout.CENTER);

    contactTable.setShowVerticalLines(true);
    contactTable.setShowHorizontalLines(false);
    contactTable.setAutoCreateColumnsFromModel(true);
    contactTable.setIntercellSpacing(new java.awt.Dimension(2, 1));
    contactTable.setBounds(0, 0, 50, 50);
    contactTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    contactTable.getSelectionModel().addListSelectionListener(this);
    contactTable.addMouseListener(new PopupListener(tablePopupMenu));
    contactTable.addMouseListener(new DoubleClickListener(new TableDoubleClickAction()));
    contactTable.setTransferHandler(new ContactTransferHandler());
    contactTable.setDragEnabled(true);

    contactTable.setDefaultRenderer(String.class, new StringCellRenderer());

    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(horizontalSplitPane, BorderLayout.CENTER);
}

From source file:es.emergya.ui.gis.FleetControlMapViewer.java

@Override
protected JPopupMenu getContextMenu() {
    JPopupMenu menu = new JPopupMenu();

    menu.setBackground(Color.decode("#E8EDF6"));

    // Ttulo// w  w  w  .  j  a v a  2 s .c  o m
    final JMenuItem titulo = new JMenuItem(i18n.getString("map.menu.titulo.puntoGenerico"));
    titulo.setFont(LogicConstants.deriveBoldFont(10.0f));
    titulo.setBackground(Color.decode("#A4A4A4"));
    titulo.setFocusable(false);

    menu.add(titulo);

    menu.addSeparator();

    // Actualizar posicin
    final JMenuItem gps = new JMenuItem(i18n.getString("map.menu.gps"), KeyEvent.VK_P);
    gps.setIcon(LogicConstants.getIcon("menucontextual_icon_actualizargps"));
    menu.add(gps);
    gps.addActionListener(this);
    gps.setEnabled(false);

    menu.addSeparator();

    // Mostrar ms cercanos
    final JMenuItem mmc = new JMenuItem(i18n.getString("map.menu.showNearest"), KeyEvent.VK_M);
    mmc.setIcon(LogicConstants.getIcon("menucontextual_icon_mascercano"));
    mmc.addActionListener(this);
    menu.add(mmc);
    // Centrar aqui
    final JMenuItem cent = new JMenuItem(i18n.getString("map.menu.centerHere"), KeyEvent.VK_C);
    cent.setIcon(LogicConstants.getIcon("menucontextual_icon_centrar"));
    cent.addActionListener(this);
    menu.add(cent);
    // Nueva Incidencia
    final JMenuItem newIncidence = new JMenuItem(i18n.getString("map.menu.newIncidence"), KeyEvent.VK_I);
    newIncidence.setIcon(LogicConstants.getIcon("menucontextual_icon_newIncidence"));
    newIncidence.addActionListener(this);
    menu.add(newIncidence);
    // Calcular ruta desde aqui
    final JMenuItem from = new JMenuItem(i18n.getString("map.menu.route.from"), KeyEvent.VK_D);
    from.setIcon(LogicConstants.getIcon("menucontextual_icon_origenruta"));
    from.addActionListener(this);
    menu.add(from);
    // Calcular ruta hasta aqui
    final JMenuItem to = new JMenuItem(i18n.getString("map.menu.route.to"), KeyEvent.VK_H);
    to.setIcon(LogicConstants.getIcon("menucontextual_icon_destinoruta"));
    to.addActionListener(this);
    menu.add(to);

    menu.addSeparator();

    // Ver ficha [recurso / incidencia]
    final JMenuItem summary = new JMenuItem(i18n.getString("map.menu.summary"), KeyEvent.VK_F);
    summary.setIcon(LogicConstants.getIcon("menucontextual_icon_ficha"));
    summary.addActionListener(this);
    menu.add(summary);
    summary.setEnabled(false);

    menu.addPopupMenuListener(new PopupMenuListener() {

        @SuppressWarnings("unchecked")
        @Override
        public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
            eventOriginal = FleetControlMapViewer.this.mapView.lastMEvent;
            gps.setEnabled(false);
            summary.setEnabled(false);
            titulo.setText(i18n.getString("map.menu.titulo.puntoGenerico"));
            menuObjective = null;
            Point p = new Point(mapView.lastMEvent.getX(), mapView.lastMEvent.getY());
            for (Layer l : mapView.getAllLayers()) { // por cada capa...
                if (l instanceof MarkerLayer) { // ...de marcadores
                    for (Marker marker : ((MarkerLayer) l).data) { // miramos
                        // los
                        // marcadores
                        if ((marker instanceof CustomMarker) && marker.containsPoint(p)) { // y si
                            // estamos
                            // pinchando
                            // en uno
                            CustomMarker m = (CustomMarker) marker;
                            log.trace("Hemos pinchado en " + marker);

                            switch (m.getType()) {
                            case RESOURCE:
                                Recurso r = (Recurso) m.getObject();
                                log.trace("Es un recurso: " + r);
                                if (r != null) {
                                    menuObjective = r;
                                    if (r.getPatrullas() != null) {
                                        titulo.setText(
                                                i18n.getString(Locale.ROOT, "map.menu.titulo.recursoPatrulla",
                                                        r.getIdentificador(), r.getPatrullas()));
                                    } else {
                                        titulo.setText(r.getIdentificador());
                                    }
                                    gps.setEnabled(true);
                                    summary.setEnabled(true);
                                }
                                break;
                            case INCIDENCE:
                                Incidencia i = (Incidencia) m.getObject();
                                log.trace("Es una incidencia: " + i);
                                if (i != null) {
                                    menuObjective = i;
                                    titulo.setText(i.getTitulo());
                                    gps.setEnabled(false);
                                    summary.setEnabled(true);
                                }
                                break;
                            case UNKNOWN:
                                log.trace("Hemos pinchado en un marcador desconocido");
                                break;
                            }

                        }
                    }
                }
            }
        }

        @Override
        public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
        }

        @Override
        public void popupMenuCanceled(PopupMenuEvent e) {
        }
    });

    return menu;
}

From source file:com.AandR.beans.plotting.LinePlotPanel.LinePlotPanel.java

private ChartPanel createChartPanel() {
    JFreeChart xyChart = ChartFactory.createXYLineChart("f", "x", "y", plotSeries, PlotOrientation.VERTICAL,
            false, true, false);//from   w ww  .  j  ava2s  . c  o  m
    RenderingHints hints = xyChart.getRenderingHints();
    hints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    hints.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    xyChart.setBackgroundPaint(Color.WHITE);

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) xyChart.getXYPlot().getRenderer();
    renderer.setBaseLinesVisible(isLineVisible);
    renderer.setBaseShapesVisible(isSymbolVisible);

    LegendTitle legend = new LegendTitle(renderer);
    legend.setPosition(RectangleEdge.BOTTOM);
    xyChart.addLegend(legend);

    xyChart.getXYPlot().getRangeAxis().setStandardTickUnits(createTickUnits());
    //xyChart.getXYPlot().getRangeAxis().setStandardTickUnits(new StandardTickUnitSource());
    xyChart.getXYPlot().getRangeAxis().setAutoRangeMinimumSize(1.0e-45);

    chartPanel = new ChartPanel(xyChart);

    JPopupMenu popup = chartPanel.getPopupMenu();
    popup.remove(1); // removes separator
    popup.remove(1); // removes save as...
    popup.add(createLinePropMenu());
    popup.add(createAxesPropMenu());
    popup.addSeparator();
    popup.add(createExportMenu());
    return chartPanel;
}

From source file:com.clank.launcher.dialog.LauncherFrame.java

/**
 * Popup the menu for the instances./*w w  w .ja  v a  2 s . c  om*/
 *
 * @param component the component
 * @param x mouse X
 * @param y mouse Y
 * @param selected the selected instance, possibly null
 */
private void popupInstanceMenu(Component component, int x, int y, final Instance selected) {
    JPopupMenu popup = new JPopupMenu();
    JMenuItem menuItem;

    if (selected != null) {
        menuItem = new JMenuItem(!selected.isLocal() ? "Install" : "Launch");
        menuItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                launch();
            }
        });
        popup.add(menuItem);

        if (selected.isLocal()) {
            popup.addSeparator();

            menuItem = new JMenuItem(_("instance.openFolder"));
            menuItem.addActionListener(
                    ActionListeners.browseDir(LauncherFrame.this, selected.getContentDir(), true));
            popup.add(menuItem);

            menuItem = new JMenuItem(_("instance.openSaves"));
            menuItem.addActionListener(ActionListeners.browseDir(LauncherFrame.this,
                    new File(selected.getContentDir(), "saves"), true));
            popup.add(menuItem);

            menuItem = new JMenuItem(_("instance.openResourcePacks"));
            menuItem.addActionListener(ActionListeners.browseDir(LauncherFrame.this,
                    new File(selected.getContentDir(), "resourcepacks"), true));
            popup.add(menuItem);

            menuItem = new JMenuItem(_("instance.openScreenshots"));
            menuItem.addActionListener(ActionListeners.browseDir(LauncherFrame.this,
                    new File(selected.getContentDir(), "screenshots"), true));
            popup.add(menuItem);

            menuItem = new JMenuItem(_("instance.copyAsPath"));
            menuItem.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    File dir = selected.getContentDir();
                    dir.mkdirs();
                    SwingHelper.setClipboard(dir.getAbsolutePath());
                }
            });
            popup.add(menuItem);

            popup.addSeparator();

            if (!selected.isUpdatePending()) {
                menuItem = new JMenuItem(_("instance.forceUpdate"));
                menuItem.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        selected.setUpdatePending(true);
                        launch();
                        instancesModel.update();
                    }
                });
                popup.add(menuItem);
            }

            menuItem = new JMenuItem(_("instance.hardForceUpdate"));
            menuItem.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    confirmHardUpdate(selected);
                }
            });
            popup.add(menuItem);

            menuItem = new JMenuItem(_("instance.deleteFiles"));
            menuItem.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    confirmDelete(selected);
                }
            });
            popup.add(menuItem);
        }

        popup.addSeparator();
    }

    menuItem = new JMenuItem(_("launcher.refreshList"));
    menuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            loadInstances();
        }
    });
    popup.add(menuItem);

    popup.show(component, x, y);

}