List of usage examples for javax.swing JPopupMenu add
public JMenuItem add(Action a)
Action
object. From source file:de.hshannover.f4.trust.visitmeta.gui.GraphConnection.java
private JPopupMenu createContextMenu(final GraphicWrapper node) { JPopupMenu result = new JPopupMenu(); for (final ContextMenuItem item : mContextMenuItems) { JMenuItem menuItem = new JMenuItem(item.getItemTitle()); menuItem.addActionListener(new ActionListener() { @Override/*from w ww . ja va 2 s . co m*/ public void actionPerformed(ActionEvent e) { item.actionPerformed(node); } }); if (!item.canHandle(node.getData())) { menuItem.setEnabled(false); } result.add(menuItem); } return result; }
From source file:biz.wolschon.finance.jgnucash.accountProperties.AccountProperties.java
private JPopupMenu createAccountIDPopupMenu() { final JPopupMenu accountIDPopupMenu = new JPopupMenu(); JMenuItem copyAccountIDMenuItem = new JMenuItem("copy"); copyAccountIDMenuItem.addActionListener(new ActionListener() { @Override/* w w w . j av a2s.co m*/ public void actionPerformed(final ActionEvent arg0) { Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(new StringSelection(myAccount.getId()), AccountProperties.this); } }); accountIDPopupMenu.add(copyAccountIDMenuItem); return accountIDPopupMenu; }
From source file:edu.ku.brc.af.ui.forms.validation.ValComboBox.java
/** * @param txtComp//from www . j av a 2 s. c om */ private void addPopupMenu(final JTextComponent txtComp) { final JPopupMenu popupMenu = new JPopupMenu(); JMenuItem mi = new JMenuItem(UIRegistry.getResourceString("DELETE")); popupMenu.add(mi); mi.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { PickListItemIFace pli = (PickListItemIFace) comboBox.getSelectedItem(); if (pli != null) { PickListIFace pl = adapter.getPickList(); pl.removeItem(pli); } } }); }
From source file:com.net2plan.gui.utils.topologyPane.TopologyPanel.java
/** * Default constructor./*from w w w.ja v a 2 s .c o m*/ * * @param callback Topology callback listening plugin events * @param defaultDesignDirectory Default location for design {@code .n2p} files (it may be null, then default is equal to {@code net2planFolder/workspace/data/networkTopologies}) * @param defaultDemandDirectory Default location for design {@code .n2p} files (it may be null, then default is equal to {@code net2planFolder/workspace/data/trafficMatrices}) * @param canvasType Canvas type (i.e. JUNG) * @param plugins List of plugins to be included (it may be null) */ public TopologyPanel(final IVisualizationCallback callback, File defaultDesignDirectory, File defaultDemandDirectory, Class<? extends ITopologyCanvas> canvasType, List<ITopologyCanvasPlugin> plugins) { File currentDir = SystemUtils.getCurrentDir(); this.callback = callback; this.defaultDesignDirectory = defaultDesignDirectory == null ? new File( currentDir + SystemUtils.getDirectorySeparator() + "workspace" + SystemUtils.getDirectorySeparator() + "data" + SystemUtils.getDirectorySeparator() + "networkTopologies") : defaultDesignDirectory; this.defaultDemandDirectory = defaultDemandDirectory == null ? new File( currentDir + SystemUtils.getDirectorySeparator() + "workspace" + SystemUtils.getDirectorySeparator() + "data" + SystemUtils.getDirectorySeparator() + "trafficMatrices") : defaultDemandDirectory; this.multilayerControlPanel = new MultiLayerControlPanel(callback); try { canvas = canvasType.getDeclaredConstructor(IVisualizationCallback.class, TopologyPanel.class) .newInstance(callback, this); } catch (Exception e) { throw new RuntimeException(e); } if (plugins != null) for (ITopologyCanvasPlugin plugin : plugins) addPlugin(plugin); setLayout(new BorderLayout()); JToolBar toolbar = new JToolBar(); toolbar.setRollover(true); toolbar.setFloatable(false); toolbar.setOpaque(false); toolbar.setBorderPainted(false); JPanel topPanel = new JPanel(new BorderLayout()); topPanel.add(toolbar, BorderLayout.NORTH); add(topPanel, BorderLayout.NORTH); JComponent canvasComponent = canvas.getCanvasComponent(); canvasPanel = new JPanel(new BorderLayout()); canvasComponent.setBorder(LineBorder.createBlackLineBorder()); JToolBar multiLayerToolbar = new JToolBar(JToolBar.VERTICAL); multiLayerToolbar.setRollover(true); multiLayerToolbar.setFloatable(false); multiLayerToolbar.setOpaque(false); canvasPanel.add(canvasComponent, BorderLayout.CENTER); canvasPanel.add(multiLayerToolbar, BorderLayout.WEST); add(canvasPanel, BorderLayout.CENTER); btn_load = new JButton(); btn_load.setToolTipText("Load a network design"); btn_loadDemand = new JButton(); btn_loadDemand.setToolTipText("Load a traffic demand set"); btn_save = new JButton(); btn_save.setToolTipText("Save current state to a file"); btn_zoomIn = new JButton(); btn_zoomIn.setToolTipText("Zoom in"); btn_zoomOut = new JButton(); btn_zoomOut.setToolTipText("Zoom out"); btn_zoomAll = new JButton(); btn_zoomAll.setToolTipText("Zoom all"); btn_takeSnapshot = new JButton(); btn_takeSnapshot.setToolTipText("Take a snapshot of the canvas"); btn_showNodeNames = new JToggleButton(); btn_showNodeNames.setToolTipText("Show/hide node names"); btn_showLinkIds = new JToggleButton(); btn_showLinkIds.setToolTipText( "Show/hide link utilization, measured as the ratio between the total traffic in the link (including that in protection segments) and total link capacity (including that reserved by protection segments)"); btn_showNonConnectedNodes = new JToggleButton(); btn_showNonConnectedNodes.setToolTipText("Show/hide non-connected nodes"); btn_increaseNodeSize = new JButton(); btn_increaseNodeSize.setToolTipText("Increase node size"); btn_decreaseNodeSize = new JButton(); btn_decreaseNodeSize.setToolTipText("Decrease node size"); btn_increaseFontSize = new JButton(); btn_increaseFontSize.setToolTipText("Increase font size"); btn_decreaseFontSize = new JButton(); btn_decreaseFontSize.setToolTipText("Decrease font size"); /* Multilayer buttons */ btn_increaseInterLayerDistance = new JButton(); btn_increaseInterLayerDistance .setToolTipText("Increase the distance between layers (when more than one layer is visible)"); btn_decreaseInterLayerDistance = new JButton(); btn_decreaseInterLayerDistance .setToolTipText("Decrease the distance between layers (when more than one layer is visible)"); btn_showLowerLayerInfo = new JToggleButton(); btn_showLowerLayerInfo .setToolTipText("Shows the links in lower layers that carry traffic of the picked element"); btn_showLowerLayerInfo.setSelected(getVisualizationState().isShowInCanvasLowerLayerPropagation()); btn_showUpperLayerInfo = new JToggleButton(); btn_showUpperLayerInfo.setToolTipText( "Shows the links in upper layers that carry traffic that appears in the picked element"); btn_showUpperLayerInfo.setSelected(getVisualizationState().isShowInCanvasUpperLayerPropagation()); btn_showThisLayerInfo = new JToggleButton(); btn_showThisLayerInfo.setToolTipText( "Shows the links in the same layer as the picked element, that carry traffic that appears in the picked element"); btn_showThisLayerInfo.setSelected(getVisualizationState().isShowInCanvasThisLayerPropagation()); btn_npChangeUndo = new JButton(); btn_npChangeUndo.setToolTipText( "Navigate back to the previous state of the network (last time the network design was changed)"); btn_npChangeRedo = new JButton(); btn_npChangeRedo.setToolTipText( "Navigate forward to the next state of the network (when network design was changed"); btn_osmMap = new JToggleButton(); btn_osmMap.setToolTipText( "Toggle between on/off the OSM support. An internet connection is required in order for this to work."); btn_tableControlWindow = new JButton(); btn_tableControlWindow.setToolTipText("Show the network topology control window."); // MultiLayer control window JPopupMenu multiLayerPopUp = new JPopupMenu(); multiLayerPopUp.add(multilayerControlPanel); JPopUpButton btn_multilayer = new JPopUpButton("", multiLayerPopUp); btn_reset = new JButton("Reset"); btn_reset.setToolTipText("Reset the user interface"); btn_reset.setMnemonic(KeyEvent.VK_R); btn_load.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/loadDesign.png"))); btn_loadDemand.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/loadDemand.png"))); btn_save.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/saveDesign.png"))); btn_showNodeNames .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showNodeName.png"))); btn_showLinkIds .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showLinkUtilization.png"))); btn_showNonConnectedNodes.setIcon( new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showNonConnectedNodes.png"))); //btn_whatIfActivated.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showNonConnectedNodes.png"))); btn_zoomIn.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/zoomIn.png"))); btn_zoomOut.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/zoomOut.png"))); btn_zoomAll.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/zoomAll.png"))); btn_takeSnapshot.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/takeSnapshot.png"))); btn_increaseNodeSize .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/increaseNode.png"))); btn_decreaseNodeSize .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/decreaseNode.png"))); btn_increaseFontSize .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/increaseFont.png"))); btn_decreaseFontSize .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/decreaseFont.png"))); btn_increaseInterLayerDistance.setIcon( new ImageIcon(TopologyPanel.class.getResource("/resources/gui/increaseLayerDistance.png"))); btn_decreaseInterLayerDistance.setIcon( new ImageIcon(TopologyPanel.class.getResource("/resources/gui/decreaseLayerDistance.png"))); btn_multilayer .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showLayerControl.png"))); btn_showThisLayerInfo .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showLayerPropagation.png"))); btn_showUpperLayerInfo.setIcon( new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showLayerUpperPropagation.png"))); btn_showLowerLayerInfo.setIcon( new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showLayerLowerPropagation.png"))); btn_tableControlWindow .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showControl.png"))); btn_osmMap.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showOSM.png"))); btn_npChangeUndo.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/undoButton.png"))); btn_npChangeRedo.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/redoButton.png"))); btn_load.addActionListener(this); btn_loadDemand.addActionListener(this); btn_save.addActionListener(this); btn_showNodeNames.addActionListener(this); btn_showLinkIds.addActionListener(this); btn_showNonConnectedNodes.addActionListener(this); btn_zoomIn.addActionListener(this); btn_zoomOut.addActionListener(this); btn_zoomAll.addActionListener(this); btn_takeSnapshot.addActionListener(this); btn_reset.addActionListener(this); btn_increaseInterLayerDistance.addActionListener(this); btn_decreaseInterLayerDistance.addActionListener(this); btn_showLowerLayerInfo.addActionListener(this); btn_showUpperLayerInfo.addActionListener(this); btn_showThisLayerInfo.addActionListener(this); btn_increaseNodeSize.addActionListener(this); btn_decreaseNodeSize.addActionListener(this); btn_increaseFontSize.addActionListener(this); btn_decreaseFontSize.addActionListener(this); btn_npChangeUndo.addActionListener(this); btn_npChangeRedo.addActionListener(this); btn_osmMap.addActionListener(this); btn_tableControlWindow.addActionListener(this); toolbar.add(btn_load); toolbar.add(btn_loadDemand); toolbar.add(btn_save); toolbar.add(new JToolBar.Separator()); toolbar.add(btn_zoomIn); toolbar.add(btn_zoomOut); toolbar.add(btn_zoomAll); toolbar.add(btn_takeSnapshot); toolbar.add(new JToolBar.Separator()); toolbar.add(btn_showNodeNames); toolbar.add(btn_showLinkIds); toolbar.add(btn_showNonConnectedNodes); toolbar.add(new JToolBar.Separator()); toolbar.add(btn_increaseNodeSize); toolbar.add(btn_decreaseNodeSize); toolbar.add(btn_increaseFontSize); toolbar.add(btn_decreaseFontSize); toolbar.add(new JToolBar.Separator()); toolbar.add(Box.createHorizontalGlue()); toolbar.add(btn_osmMap); toolbar.add(btn_tableControlWindow); toolbar.add(btn_reset); multiLayerToolbar.add(new JToolBar.Separator()); multiLayerToolbar.add(btn_multilayer); multiLayerToolbar.add(btn_increaseInterLayerDistance); multiLayerToolbar.add(btn_decreaseInterLayerDistance); multiLayerToolbar.add(btn_showLowerLayerInfo); multiLayerToolbar.add(btn_showUpperLayerInfo); multiLayerToolbar.add(btn_showThisLayerInfo); multiLayerToolbar.add(Box.createVerticalGlue()); multiLayerToolbar.add(btn_npChangeUndo); multiLayerToolbar.add(btn_npChangeRedo); this.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { if (e.getComponent().getSize().getHeight() != 0 && e.getComponent().getSize().getWidth() != 0) { canvas.zoomAll(); } } }); List<Component> children = SwingUtils.getAllComponents(this); for (Component component : children) if (component instanceof AbstractButton) component.setFocusable(false); if (ErrorHandling.isDebugEnabled()) { canvas.getCanvasComponent().addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseMoved(MouseEvent e) { Point point = e.getPoint(); position.setText("view = " + point + ", NetPlan coord = " + canvas.getCanvasPointFromNetPlanPoint(point)); } }); position = new JLabel(); add(position, BorderLayout.SOUTH); } else { position = null; } new FileDrop(canvasComponent, new LineBorder(Color.BLACK), new FileDrop.Listener() { @Override public void filesDropped(File[] files) { for (File file : files) { try { if (!file.getName().toLowerCase(Locale.getDefault()).endsWith(".n2p")) return; loadDesignFromFile(file); break; } catch (Throwable e) { break; } } } }); btn_showNodeNames.setSelected(getVisualizationState().isCanvasShowNodeNames()); btn_showLinkIds.setSelected(getVisualizationState().isCanvasShowLinkLabels()); btn_showNonConnectedNodes.setSelected(getVisualizationState().isCanvasShowNonConnectedNodes()); final ITopologyCanvasPlugin popupPlugin = new PopupMenuPlugin(callback, this.canvas); addPlugin(new PanGraphPlugin(callback, canvas, MouseEvent.BUTTON1_MASK)); if (callback.getVisualizationState().isNetPlanEditable() && getCanvas() instanceof JUNGCanvas) addPlugin(new AddLinkGraphPlugin(callback, canvas, MouseEvent.BUTTON1_MASK, MouseEvent.BUTTON1_MASK | MouseEvent.SHIFT_MASK)); addPlugin(popupPlugin); if (callback.getVisualizationState().isNetPlanEditable()) addPlugin(new MoveNodePlugin(callback, canvas, MouseEvent.BUTTON1_MASK | MouseEvent.CTRL_MASK)); setBorder(BorderFactory.createTitledBorder(new LineBorder(Color.BLACK), "Network topology")); // setAllowLoadTrafficDemand(callback.allowLoadTrafficDemands()); }
From source file:com.googlecode.bpmn_simulator.gui.BPMNSimulatorFrame.java
private JToolBar createDefinitionToolbar() { final JButton openButton = new JButton(Theme.ICON_OPEN); openButton.setToolTipText(Messages.getString("Toolbar.open")); //$NON-NLS-1$ openButton.addActionListener(new ActionListener() { @Override/*from w w w. ja v a2 s . c o m*/ public void actionPerformed(final ActionEvent event) { openFile(); } }); definitionToolbar.add(openButton); final JPopupMenu importMenu = new JPopupMenu(Messages.getString("Toolbar.import")); //$NON-NLS-1$ final JMenuItem importBonitaItem = new JMenuItem("Bonita"); importBonitaItem.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent event) { importBonita(); } }); importMenu.add(importBonitaItem); final JButton importButton = new JButton(Theme.ICON_IMPORT); importButton.setToolTipText(Messages.getString("Toolbar.import")); //$NON-NLS-1$ importButton.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent event) { importMenu.show(importButton, 0, importButton.getHeight()); } }); definitionToolbar.add(importButton); return definitionToolbar; }
From source file:com.frostwire.gui.bittorrent.BTDownloadMediator.java
protected JPopupMenu createPopupMenu() { JPopupMenu menu = new SkinPopupMenu(); if (playSingleAudioFileAction.isEnabled()) { menu.add(new SkinMenuItem(playSingleAudioFileAction)); }/*from ww w. jav a 2 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:jatoo.app.App.java
private JPopupMenu getWindowPopup(final Point location) { ////w ww. j a va 2s . c o m // 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./*from w w w .j a v a 2 s .co 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:maltcms.ui.fileHandles.csv.CSVTableView.java
private void createAndShowPopupMenu(MouseEvent me) { if (me.getButton() == MouseEvent.BUTTON3 && this.jTable1.getSelectedRowCount() > 0 && this.jfctc != null) { JPopupMenu jpm = new JPopupMenu(); //more than one column selected if (jTable1.getSelectedColumnCount() > 0) { jpm.add(new AbstractAction("Add as y-values") { @Override/*from ww w.ja v a 2s.co m*/ public void actionPerformed(ActionEvent ae) { for (int col : jTable1.getSelectedColumns()) { columnsToPlot.add(col); jTable1.getColumnModel().getColumn(col).setCellRenderer(new ColorColumnRenderer( new Color(238, 187, 0, 255), jTable1.getSelectedRows())); } jfctc.setChart( buildChart(labelColumn, domainColumn, columnsToPlot, jTable1.getSelectedRows())); } }); //selected rows for (final int col : jTable1.getSelectedColumns()) { if (columnsToPlot.contains(col)) { jpm.add(new AbstractAction("Remove y-values from chart") { @Override public void actionPerformed(ActionEvent ae) { jTable1.getColumnModel().getColumn(col).setCellRenderer( new ColorColumnRenderer(Color.WHITE, jTable1.getSelectedRows())); columnsToPlot.remove(col); jfctc.setChart(buildChart(labelColumn, domainColumn, columnsToPlot, jTable1.getSelectedRows())); } }); break; } } jpm.add(new JPopupMenu.Separator()); jpm.add(new AbstractAction("Log10 transform") { @Override public void actionPerformed(ActionEvent ae) { final int[] cols = jTable1.getSelectedColumns(); for (int i = 0; i < jTable1.getSelectedColumnCount(); i++) { logTransformColumn(cols[i], 10.0d); } } }); jpm.add(new AbstractAction("Inverse Log10 transform") { @Override public void actionPerformed(ActionEvent ae) { final int[] cols = jTable1.getSelectedColumns(); for (int i = 0; i < jTable1.getSelectedColumnCount(); i++) { inverseLogTransformColumn(cols[i], 10.0d); } } }); } jpm.add(new JPopupMenu.Separator()); //exactly one selected column, no domain column if (jTable1.getSelectedColumnCount() == 1 && domainColumn == -1) { jpm.add(new AbstractAction("Set as x-values") { @Override public void actionPerformed(ActionEvent ae) { domainColumn = jTable1.getSelectedColumn(); jTable1.getColumnModel().getColumn(domainColumn).setCellRenderer( new ColorColumnRenderer(new Color(255, 0, 0, 255), jTable1.getSelectedRows())); jfctc.setChart( buildChart(labelColumn, domainColumn, columnsToPlot, jTable1.getSelectedRows())); } }); } //one domainColumn if (domainColumn != -1) { jpm.add(new AbstractAction("Reset x-axis values") { @Override public void actionPerformed(ActionEvent ae) { jTable1.getColumnModel().getColumn(domainColumn).setCellRenderer( new ColorColumnRenderer(new Color(255, 255, 255, 255), jTable1.getSelectedRows())); domainColumn = -1; jfctc.setChart( buildChart(labelColumn, domainColumn, columnsToPlot, jTable1.getSelectedRows())); } }); } jpm.add(new JPopupMenu.Separator()); if (jTable1.getSelectedColumnCount() == 1 && labelColumn == -1) { jpm.add(new AbstractAction("Set as series labels") { @Override public void actionPerformed(ActionEvent ae) { labelColumn = jTable1.getSelectedColumn(); jTable1.getColumnModel().getColumn(labelColumn).setCellRenderer( new ColorColumnRenderer(new Color(255, 255, 0, 255), jTable1.getSelectedRows())); jfctc.setChart( buildChart(labelColumn, domainColumn, columnsToPlot, jTable1.getSelectedRows())); } }); } if (jTable1.getSelectedColumnCount() == 1 && labelColumn != -1) { jpm.add(new AbstractAction("Reset series labels") { @Override public void actionPerformed(ActionEvent ae) { jTable1.getColumnModel().getColumn(labelColumn).setCellRenderer( new ColorColumnRenderer(new Color(255, 255, 255, 255), jTable1.getSelectedRows())); labelColumn = -1; jfctc.setChart( buildChart(labelColumn, domainColumn, columnsToPlot, jTable1.getSelectedRows())); } }); } jpm.show(me.getComponent(), me.getX(), me.getY()); } }
From source file:me.mayo.telnetkek.MainPanel.java
public final void setupTablePopup() { this.tblPlayers.addMouseListener(new MouseAdapter() { @Override//from w w w . j ava 2 s . c om 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()); } } } }); }