List of usage examples for javax.swing JPopupMenu addSeparator
public void addSeparator()
From source file:de.ailis.xadrian.components.ComplexEditor.java
/** * Constructor// w w w. j a v a 2s. co m * * @param complex * The complex to edit * @param file * The file from which the complex was loaded. Null if it not * loaded from a file. */ public ComplexEditor(final Complex complex, final File file) { super(); setLayout(new BorderLayout()); this.complex = complex; this.file = file; // Create the text pane this.textPane = new JTextPane(); this.textPane.setEditable(false); this.textPane.setBorder(null); this.textPane.setContentType("text/html"); this.textPane.setDoubleBuffered(true); this.textPane.addHyperlinkListener(this); this.textPane.addCaretListener(this); // Create the popup menu for the text pane final JPopupMenu popupMenu = new JPopupMenu(); popupMenu.add(new CopyAction(this)); popupMenu.add(new SelectAllAction(this)); popupMenu.addSeparator(); popupMenu.add(new AddFactoryAction(this)); popupMenu.add(new ChangeSectorAction(this.complex, this, "complex")); popupMenu.add(new ChangeSunsAction(this)); popupMenu.add(new ChangePricesAction(this)); popupMenu.add(new JCheckBoxMenuItem(new ToggleBaseComplexAction(this))); SwingUtils.setPopupMenu(this.textPane, popupMenu); final HTMLDocument document = (HTMLDocument) this.textPane.getDocument(); // Set the base URL of the text pane document.setBase(Main.class.getResource("templates/")); // Modify the body style so it matches the system font final Font font = UIManager.getFont("Label.font"); final String bodyRule = "body { font-family: " + font.getFamily() + "; font-size: " + font.getSize() + "pt; }"; document.getStyleSheet().addRule(bodyRule); // Create the scroll pane final JScrollPane scrollPane = new JScrollPane(this.textPane); add(scrollPane); // Redraw the content redraw(); fireComplexState(); }
From source file:org.gumtree.vis.awt.time.TimePlotPanel.java
@Override protected JPopupMenu createPopupMenu(boolean properties, boolean copy, boolean save, boolean print, boolean zoom) { JPopupMenu menu = super.createPopupMenu(properties, copy, save, print, zoom); menu.addSeparator(); legendMenu = new JMenu("Legend Position"); menu.add(legendMenu);/* www .j a v a 2s .c o m*/ legendNone = new JRadioButtonMenuItem("None"); legendNone.setActionCommand(LEGEND_NONE_COMMAND); legendNone.addActionListener(this); legendMenu.add(legendNone); legendBottom = new JRadioButtonMenuItem("Bottom"); legendBottom.setActionCommand(LEGEND_BOTTOM_COMMAND); legendBottom.addActionListener(this); legendMenu.add(legendBottom); legendRight = new JRadioButtonMenuItem("Right"); legendRight.setActionCommand(LEGEND_RIGHT_COMMAND); legendRight.addActionListener(this); legendMenu.add(legendRight); menu.addSeparator(); curveManagementMenu = new JMenu("Focus on Curve"); menu.add(curveManagementMenu); menu.addSeparator(); showMultiAxesMenuItem = new JCheckBoxMenuItem("Show Multiple Vertical Axes"); showMultiAxesMenuItem.setActionCommand(SHOW_MULTI_AXES_COMMAND); showMultiAxesMenuItem.addActionListener(this); menu.add(showMultiAxesMenuItem); menu.addSeparator(); curveResetMenu = new JMenu("Reset Curve"); menu.add(curveResetMenu); menu.addSeparator(); pauseMenuItem = new JCheckBoxMenuItem("Paused"); pauseMenuItem.setActionCommand(TOGGLE_PAUSED_COMMAND); pauseMenuItem.addActionListener(this); menu.add(pauseMenuItem); return menu; }
From source file:jatoo.app.App.java
private JPopupMenu getWindowPopup(final Point location) { ////from w w w.j a va2 s .com // hide final JMenuItem hideItem = new JMenuItem(getText("popup.hide")); hideItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { hide(); } }); // // send to back final JMenuItem sendToBackItem = new JMenuItem(getText("popup.send_to_back")); sendToBackItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { sendToBack(); } }); // // always on top final JCheckBoxMenuItem alwaysOnTopItem = new JCheckBoxMenuItem(getText("popup.always_on_top"), isAlwaysOnTop()); alwaysOnTopItem.addItemListener(new ItemListener() { public void itemStateChanged(final ItemEvent e) { setAlwaysOnTop(alwaysOnTopItem.isSelected()); } }); // // transparency final JSlider transparencySlider = new JSlider(JSlider.VERTICAL, 0, 100, getTransparency()); transparencySlider.setMajorTickSpacing(25); transparencySlider.setMinorTickSpacing(5); transparencySlider.setSnapToTicks(true); transparencySlider.setPaintTicks(true); transparencySlider.setPaintLabels(true); transparencySlider.addChangeListener(new ChangeListener() { public void stateChanged(final ChangeEvent e) { setTransparency(transparencySlider.getValue()); } }); final JMenu transparencyItem = new JMenu(getText("popup.transparency")); transparencyItem.add(transparencySlider); // // close final JMenuItem closeItem = new JMenuItem(getText("popup.close"), getIcon("close-016.png")); closeItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { System.exit(0); } }); // // the popup JPopupMenu popup = new JPopupMenu(getTitle()); popup.add(hideItem); popup.addSeparator(); popup.add(sendToBackItem); popup.add(alwaysOnTopItem); popup.add(transparencyItem); popup.addSeparator(); popup.add(closeItem); popup.setInvoker(popup); popup.setLocation(location); return popup; }
From source file:ipnat.skel.Strahler.java
/** * Gets the analysis parameters from the user. * * @return {@code true} if the dialog input is valid and dialog was not * dismissed.// w ww . j a va 2 s . c o m */ boolean getSettings() { final EnhancedGenericDialog gd = new EnhancedGenericDialog("Strahler Analysis :: " + IPNAT.getVersion()); final Font headerFont = new Font("SansSerif", Font.BOLD, 12); gd.setSmartRecording(true); // Part 1. Main Options gd.setInsets(0, 0, 0); gd.addMessage("Tree Classification:", headerFont); gd.addCheckbox("Infer root end-points from rectangular ROI", protectRoot); gd.addCheckbox("Ignore single-point arbors (Isolated pixels)", erodeIsolatedPixels); // Part 2: Loop elimination gd.setInsets(25, 0, 0); gd.addMessage("Elimination of Skeleton Loops:", headerFont); gd.addChoice("Method:", AnalyzeSkeleton_.pruneCyclesModes, AnalyzeSkeleton_.pruneCyclesModes[pruneChoice]); // 8-bit grayscale is the only image type recognized by // AnalyzeSkeleton_, // so we'll provide the user with a pre-filtered list of valid choices final ArrayList<Integer> validIds = new ArrayList<Integer>(); final ArrayList<String> validTitles = new ArrayList<String>(); final int[] ids = WindowManager.getIDList(); for (int i = 0; i < ids.length; ++i) { final ImagePlus imp = WindowManager.getImage(ids[i]); if (imp.getBitDepth() == 8) { // TODO: ignore composites? validIds.add(ids[i]); validTitles.add(imp.getTitle()); } } gd.addChoice("8-bit grayscale image:", validTitles.toArray(new String[validTitles.size()]), title); // Part 3: Output gd.setInsets(25, 0, 0); gd.addMessage("Output Options:", headerFont); gd.addCheckbox("Display_iteration stack", outIS); gd.addCheckbox("Show detailed information", verbose); gd.addCheckbox("Tabular data only (no image output)", tabular); gd.addDialogListener(this); dialogItemChanged(gd, null); // update prompt // Add More>> dropdown menu final JPopupMenu popup = new JPopupMenu(); JMenuItem mi; mi = new JMenuItem("Online documentation"); mi.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { IJ.runPlugIn("ij.plugin.BrowserLauncher", URL); } }); popup.add(mi); popup.addSeparator(); mi = new JMenuItem("List hIPNAT commands..."); mi.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { IJ.runPlugIn("ij.plugin.BrowserLauncher", IPNAT.DOC_URL + "#List_of_commands"); } }); popup.add(mi); mi = new JMenuItem("About hIPNAT plugins..."); mi.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { IJ.runPlugIn("ipnat.Help", ""); } }); popup.add(mi); gd.assignPopupToHelpButton(popup); gd.showDialog(); // Set grayscale image for intensity-based pruning of skel. loops. if (pruneChoice == AnalyzeSkeleton_.LOWEST_INTENSITY_VOXEL || pruneChoice == AnalyzeSkeleton_.LOWEST_INTENSITY_BRANCH) { grayscaleImp = WindowManager.getImage(validIds.get(grayscaleImpChoice)); } else { grayscaleImp = null; } return gd.wasOKed(); }
From source file:me.mayo.telnetkek.MainPanel.java
public final void setupTablePopup() { this.tblPlayers.addMouseListener(new MouseAdapter() { @Override//from w w w .j av a 2 s . c o m public void mouseReleased(final MouseEvent mouseEvent) { final JTable table = MainPanel.this.tblPlayers; final int r = table.rowAtPoint(mouseEvent.getPoint()); if (r >= 0 && r < table.getRowCount()) { table.setRowSelectionInterval(r, r); } else { table.clearSelection(); } final int rowindex = table.getSelectedRow(); if (rowindex < 0) { return; } if ((SwingUtilities.isRightMouseButton(mouseEvent) || mouseEvent.isControlDown()) && mouseEvent.getComponent() instanceof JTable) { final PlayerInfo player = getSelectedPlayer(); if (player != null) { final JPopupMenu popup = new JPopupMenu(player.getName()); final JMenuItem header = new JMenuItem("Apply action to " + player.getName() + ":"); header.setEnabled(false); popup.add(header); popup.addSeparator(); final ActionListener popupAction = (ActionEvent actionEvent) -> { Object _source = actionEvent.getSource(); if (_source instanceof PlayerListPopupItem_Command) { final PlayerListPopupItem_Command source = (PlayerListPopupItem_Command) _source; final String output = source.getCommand().buildOutput(source.getPlayer(), true); MainPanel.this.getConnectionManager().sendDelayedCommand(output, true, 100); } else if (_source instanceof PlayerListPopupItem) { final PlayerListPopupItem source = (PlayerListPopupItem) _source; final PlayerInfo _player = source.getPlayer(); switch (actionEvent.getActionCommand()) { case "Copy IP": { copyToClipboard(_player.getIp()); MainPanel.this.writeToConsole( new ConsoleMessage("Copied IP to clipboard: " + _player.getIp())); break; } case "Copy Name": { copyToClipboard(_player.getName()); MainPanel.this.writeToConsole( new ConsoleMessage("Copied name to clipboard: " + _player.getName())); break; } case "Copy UUID": { copyToClipboard(_player.getUuid()); MainPanel.this.writeToConsole( new ConsoleMessage("Copied UUID to clipboard: " + _player.getUuid())); break; } } } }; TelnetKek.config.getCommands().stream().map( (command) -> new PlayerListPopupItem_Command(command.getName(), player, command)) .map((item) -> { item.addActionListener(popupAction); return item; }).forEach((item) -> { popup.add(item); }); popup.addSeparator(); JMenuItem item; item = new PlayerListPopupItem("Copy Name", player); item.addActionListener(popupAction); popup.add(item); item = new PlayerListPopupItem("Copy IP", player); item.addActionListener(popupAction); popup.add(item); item = new PlayerListPopupItem("Copy UUID", player); item.addActionListener(popupAction); popup.add(item); popup.show(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY()); } } } }); }
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(); menu.add(new JMenuItem(RESUME_ACTION)); menu.addSeparator();//from w w w. j av a 2 s .com 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:ca.phon.app.project.ProjectWindow.java
/** * Displays the session list menu/*from w ww.ja v a2s . c om*/ * * @param clickPoint */ private void showSessionListContextMenu(Point clickPoint) { List<String> selectedSessions = getSelectedSessionNames(); JPopupMenu contextMenu = new JPopupMenu(); if (selectedSessions.size() == 1) { // open item JMenuItem openItem = new JMenuItem(new OpenSessionAction(this)); contextMenu.add(openItem); contextMenu.addSeparator(); } // rename item JMenuItem duplicateItem = new JMenuItem(new DuplicateSessionAction(this)); if (selectedSessions.size() > 1) { duplicateItem.setText("Duplicate Sessions"); } contextMenu.add(duplicateItem); if (selectedSessions.size() == 1) { JMenuItem renameItem = new JMenuItem(new RenameSessionAction(this)); contextMenu.add(renameItem); } // delete item JMenuItem deleteItem = new JMenuItem(new DeleteSessionAction(this)); if (selectedSessions.size() > 1) { deleteItem.setText("Delete Sessions"); } contextMenu.add(deleteItem); contextMenu.show(sessionList, clickPoint.x, clickPoint.y); }
From source file:ca.phon.app.project.ProjectWindow.java
/** * Displays the corpus list menu/* ww w . j a va2s . co m*/ * * @param clickPoint */ private void showCorpusListContextMenu(Point clickPoint) { List<String> corpora = getSelectedCorpora(); JPopupMenu contextMenu = new JPopupMenu(); if (corpora.size() == 1) { // new session item JMenuItem newSessionItem = new JMenuItem(new NewSessionAction(this)); contextMenu.add(newSessionItem); contextMenu.addSeparator(); JMenuItem templateItem = new JMenuItem(new OpenCorpusTemplateAction(this)); contextMenu.add(templateItem); contextMenu.addSeparator(); } JMenuItem dupItem = new JMenuItem(new DuplicateCorpusAction(this)); if (corpora.size() > 1) { dupItem.setText("Duplicate Corpora"); } contextMenu.add(dupItem); if (corpora.size() == 1) { // rename JMenuItem renameItem = new JMenuItem(new RenameCorpusAction(this)); contextMenu.add(renameItem); } // delete JMenuItem deleteItem = new JMenuItem(new DeleteCorpusAction(this)); if (corpora.size() > 1) { deleteItem.setText("Delete Corpora"); } contextMenu.add(deleteItem); contextMenu.show(corpusList, clickPoint.x, clickPoint.y); }
From source file:com.frostwire.gui.bittorrent.BTDownloadMediator.java
protected JPopupMenu createPopupMenu() { JPopupMenu menu = new SkinPopupMenu(); if (playSingleAudioFileAction.isEnabled()) { menu.add(new SkinMenuItem(playSingleAudioFileAction)); }/* ww w. j ava2 s . c o m*/ menu.add(new SkinMenuItem(resumeAction)); menu.add(new SkinMenuItem(pauseAction)); if (OSUtils.isWindows() || OSUtils.isMacOSX()) { menu.add(new SkinMenuItem(showInLibraryAction)); menu.add(new SkinMenuItem(exploreAction)); } menu.addSeparator(); menu.add(new SkinMenuItem(shareTorrentAction)); if (OSUtils.isMacOSX() || OSUtils.isWindows()) { menu.add(new SkinMenuItem(sendToItunesAction)); } menu.add(new SkinMenuItem(copyMagnetAction)); menu.add(new SkinMenuItem(copyHashAction)); SkinMenu addToPlaylistMenu = BTDownloadMediatorAdvancedMenuFactory.createAddToPlaylistSubMenu(); if (addToPlaylistMenu != null) { menu.add(addToPlaylistMenu); } menu.addSeparator(); menu.add(new SkinMenuItem(removeAction)); menu.add(new SkinMenuItem(BTDownloadActions.REMOVE_TORRENT_ACTION)); menu.add(new SkinMenuItem(BTDownloadActions.REMOVE_TORRENT_AND_DATA_ACTION)); menu.add(new SkinMenuItem(removeYouTubeAction)); menu.addSeparator(); menu.add(new SkinMenuItem(BTDownloadActions.TOGGLE_SEEDS_VISIBILITY_ACTION)); SkinMenu advancedMenu = BTDownloadMediatorAdvancedMenuFactory.createAdvancedSubMenu(); if (advancedMenu != null) { menu.addSeparator(); menu.add(advancedMenu); } return menu; }
From source file:fi.elfcloud.client.tree.DataItemNode.java
private void populatePopupMenu(JPopupMenu menu, BeaverGUI gui) { JMenuItem item;// www . j a va 2s . c o m item = new JMenuItem(Messages.getString("DataItemNode.popup_download")); //$NON-NLS-1$ item.setActionCommand(Integer.toString(gui.ACTION_SAVE_ITEM)); item.addActionListener(gui); item.setIcon(new ImageIcon(BeaverGUI.class.getResource("icons/download16.png"))); //$NON-NLS-1$ menu.add(item); item = new JMenuItem(Messages.getString("DataItemNode.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("DataItemNode.popup_move")); //$NON-NLS-1$ item.setActionCommand(Integer.toString(gui.ACTION_MOVE)); item.setIcon(new ImageIcon(BeaverGUI.class.getResource("icons/move_file16.png"))); //$NON-NLS-1$ item.addActionListener(gui); menu.add(item); item = new JMenuItem(Messages.getString("DataItemNode.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("DataItemNode.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); }