List of usage examples for javax.swing JPopupMenu add
public JMenuItem add(Action a)
Action
object. From source file:eu.europa.ec.markt.dss.applet.view.validationpolicy.EditView.java
private void nodeActionAdd(MouseEvent mouseEvent, final int selectedRow, final TreePath selectedPath, final XmlDomAdapterNode clickedItem, final JTree tree) { final Element clickedElement = (Element) clickedItem.node; // popup menu for list -> add final JPopupMenu popup = new JPopupMenu(); //delete node final JMenuItem menuItemToDelete = new JMenuItem(ResourceUtils.getI18n("DELETE")); menuItemToDelete.addActionListener(new ActionListener() { @Override/*from www . j a v a2s . c om*/ public void actionPerformed(ActionEvent actionEvent) { // find the order# of the child to delete final int index = clickedItem.getParent().index(clickedItem); Node oldChild = clickedElement.getParentNode().removeChild(clickedElement); if (index > -1) { validationPolicyTreeModel.fireTreeNodesRemoved(selectedPath.getParentPath(), index, oldChild); } } }); popup.add(menuItemToDelete); //Add node/value final Map<XsdNode, Object> xsdTree = validationPolicyTreeModel.getXsdTree(); final List<XsdNode> children = getChildrenToAdd(clickedElement, xsdTree); for (final XsdNode xsdChild : children) { final String xmlName = xsdChild.getLastNameOfPath(); final JMenuItem menuItem = new JMenuItem(ResourceUtils.getI18n("ADD") + " (" + xmlName + " " + xsdChild.getType().toString().toLowerCase() + ")"); popup.add(menuItem); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { Document document = getModel().getValidationPolicy().getDocument(); final Node newElement; if (xsdChild.getType() == XsdNodeType.TEXT) { // TEXT element always appended (last child) newElement = clickedElement.appendChild(document.createTextNode("VALUE")); } else if (xsdChild.getType() == XsdNodeType.ATTRIBUTE) { newElement = document.createAttributeNS(null, xmlName); ((Attr) newElement).setValue("VALUE"); clickedElement.setAttributeNode((Attr) newElement); } else if (xsdChild.getType() == XsdNodeType.ELEMENT) { final Element childToAdd = document .createElementNS("http://dss.markt.ec.europa.eu/validation/diagnostic", xmlName); // find the correct possition to add the child // Get all allowed children Map<XsdNode, Object> childrenMap = getChild(getXPath(clickedElement), xsdTree); boolean toAddSeen = false; Element elementIsToAddBeforeThisOne = null; for (final XsdNode allowed : childrenMap.keySet()) { if (!toAddSeen && allowed == xsdChild) { toAddSeen = true; continue; } if (toAddSeen) { final NodeList elementsByTagNameNS = clickedElement.getElementsByTagNameNS( "http://dss.markt.ec.europa.eu/validation/diagnostic", allowed.getLastNameOfPath()); if (elementsByTagNameNS.getLength() > 0) { // we found an element that is supposed to be after the one to add elementIsToAddBeforeThisOne = (Element) elementsByTagNameNS.item(0); break; } } } if (elementIsToAddBeforeThisOne != null) { newElement = clickedElement.insertBefore(childToAdd, elementIsToAddBeforeThisOne); } else { newElement = clickedElement.appendChild(childToAdd); } } else { throw new IllegalArgumentException("Unknow XsdNode NodeType " + xsdChild.getType()); } document.normalizeDocument(); int indexOfAddedItem = 0; final int childCount = clickedItem.childCount(); for (int i = 0; i < childCount; i++) { if (clickedItem.child(i).node == newElement) { indexOfAddedItem = i; break; } } TreeModelEvent event = new TreeModelEvent(validationPolicyTreeModel, selectedPath, new int[] { indexOfAddedItem }, new Object[] { newElement }); validationPolicyTreeModel.fireTreeNodesInserted(event); tree.expandPath(selectedPath); //Update model getModel().getValidationPolicy().setXmlDom(new XmlDom(document)); } }); } popup.show(tree, mouseEvent.getX(), mouseEvent.getY()); }
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();//from w w w . j a v a 2 s .c om legendMenu = new JMenu("Legend Position"); menu.add(legendMenu); 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:eu.europa.esig.dss.applet.view.validationpolicy.EditView.java
private void nodeActionAdd(MouseEvent mouseEvent, final int selectedRow, final TreePath selectedPath, final XmlDomAdapterNode clickedItem, final JTree tree) { final Element clickedElement = (Element) clickedItem.node; // popup menu for list -> add final JPopupMenu popup = new JPopupMenu(); //delete node final JMenuItem menuItemToDelete = new JMenuItem(ResourceUtils.getI18n("DELETE")); menuItemToDelete.addActionListener(new ActionListener() { @Override/*from www .j ava2 s . c om*/ public void actionPerformed(ActionEvent actionEvent) { // find the order# of the child to delete final int index = clickedItem.getParent().index(clickedItem); Node oldChild = clickedElement.getParentNode().removeChild(clickedElement); if (index > -1) { validationPolicyTreeModel.fireTreeNodesRemoved(selectedPath.getParentPath(), index, oldChild); } } }); popup.add(menuItemToDelete); //Add node/value final Map<XsdNode, Object> xsdTree = validationPolicyTreeModel.getXsdTree(); final List<XsdNode> children = getChildrenToAdd(clickedElement, xsdTree); for (final XsdNode xsdChild : children) { final String xmlName = xsdChild.getLastNameOfPath(); final JMenuItem menuItem = new JMenuItem(ResourceUtils.getI18n("ADD") + " (" + xmlName + " " + xsdChild.getType().toString().toLowerCase() + ")"); popup.add(menuItem); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { Document document = getModel().getValidationPolicy().getDocument(); final Node newElement; if (xsdChild.getType() == XsdNodeType.TEXT) { // TEXT element always appended (last child) newElement = clickedElement.appendChild(document.createTextNode("VALUE")); } else if (xsdChild.getType() == XsdNodeType.ATTRIBUTE) { newElement = document.createAttributeNS(null, xmlName); ((Attr) newElement).setValue("VALUE"); clickedElement.setAttributeNode((Attr) newElement); } else if (xsdChild.getType() == XsdNodeType.ELEMENT) { final Element childToAdd = document .createElementNS("http://dss.esig.europa.eu/validation/diagnostic", xmlName); // find the correct possition to add the child // Get all allowed children Map<XsdNode, Object> childrenMap = getChild(getXPath(clickedElement), xsdTree); boolean toAddSeen = false; Element elementIsToAddBeforeThisOne = null; for (final XsdNode allowed : childrenMap.keySet()) { if (!toAddSeen && (allowed == xsdChild)) { toAddSeen = true; continue; } if (toAddSeen) { final NodeList elementsByTagNameNS = clickedElement.getElementsByTagNameNS( "http://dss.esig.europa.eu/validation/diagnostic", allowed.getLastNameOfPath()); if (elementsByTagNameNS.getLength() > 0) { // we found an element that is supposed to be after the one to add elementIsToAddBeforeThisOne = (Element) elementsByTagNameNS.item(0); break; } } } if (elementIsToAddBeforeThisOne != null) { newElement = clickedElement.insertBefore(childToAdd, elementIsToAddBeforeThisOne); } else { newElement = clickedElement.appendChild(childToAdd); } } else { throw new IllegalArgumentException("Unknow XsdNode NodeType " + xsdChild.getType()); } document.normalizeDocument(); int indexOfAddedItem = 0; final int childCount = clickedItem.childCount(); for (int i = 0; i < childCount; i++) { if (clickedItem.child(i).node == newElement) { indexOfAddedItem = i; break; } } TreeModelEvent event = new TreeModelEvent(validationPolicyTreeModel, selectedPath, new int[] { indexOfAddedItem }, new Object[] { newElement }); validationPolicyTreeModel.fireTreeNodesInserted(event); tree.expandPath(selectedPath); //Update model getModel().getValidationPolicy().setXmlDom(new XmlDom(document)); } }); } popup.show(tree, mouseEvent.getX(), mouseEvent.getY()); }
From source file:unikn.dbis.univis.visualization.graph.plaf.VGraphUI.java
/** * Creates the listener responsible for calling the correct handlers based * on mouse events, and to select invidual cells. *///www .j a va 2 s .co m protected MouseListener createMouseListener() { return new MouseHandler() { /** * Invoked when a mouse button has been pressed on a component. * //@Override public void mousePressed(MouseEvent e) { Object o = graph.getFirstCellForLocation(e.getX(), e.getY()); if (o instanceof VGraphCell) { VGraphCell cell = (VGraphCell) o; JPopupMenu menu = new JPopupMenu(); VChartPanel chartPanel = (VChartPanel) cell.getUserObject(); if (chartPanel.isShowPopUp()) { LegendItemCollection collect = chartPanel.getChart().getPlot().getLegendItems(); JMenu first = new JMenu("1-39"); int checker = 0; for (Iterator iter = collect.iterator(); iter.hasNext();) { LegendItem item = (LegendItem) iter.next(); checker++; first.add(new JMenuItem(item.getLabel())); if ((checker % 40) == 0) { menu.add(first); first = new JMenu("" + checker + "-" + (checker + 39)); } if (!iter.hasNext()) { menu.add(first); } } menu.show(graph, e.getX(), e.getY()); } } super.mousePressed(e); } */ /** * Invoked when a mouse button has been pressed on a component. */ @Override public void mousePressed(MouseEvent e) { Object o = graph.getFirstCellForLocation(e.getX(), e.getY()); if (SwingUtilities.isLeftMouseButton(e) && e.isAltDown()) { if (o instanceof VGraphCell) { VGraphCell cell = (VGraphCell) o; JPopupMenu menu = new JPopupMenu(); VChartPanel chartPanel = (VChartPanel) cell.getUserObject(); LegendItemCollection collect = chartPanel.getChart().getPlot().getLegendItems(); JMenu first = new JMenu("1-39"); int checker = 0; for (Iterator iter = collect.iterator(); iter.hasNext();) { LegendItem item = (LegendItem) iter.next(); checker++; first.add(new JMenuItem(item.getLabel())); if ((checker % 40) == 0) { menu.add(first); first = new JMenu("" + checker + "-" + (checker + 39)); } if (!iter.hasNext()) { menu.add(first); } } menu.show(graph, e.getX(), e.getY()); } } super.mousePressed(e); if (o != null && o instanceof VGraphCell) { VGraphCell cell = (VGraphCell) o; o = cell.getUserObject(); if (o != null && o instanceof VChartPanel) { VChartPanel chart = (VChartPanel) o; for (MouseListener l : chart.getMouseListeners()) { l.mousePressed(e); } } } } // Event may be null when called to cancel the current operation. @Override public void mouseReleased(MouseEvent e) { super.mouseReleased(e); Object o = graph.getFirstCellForLocation(e.getX(), e.getY()); if (o != null && o instanceof VGraphCell) { VGraphCell cell = (VGraphCell) o; o = cell.getUserObject(); if (o != null && o instanceof VChartPanel) { VChartPanel chart = (VChartPanel) o; for (MouseListener l : chart.getMouseListeners()) { l.mouseReleased(e); } } } } /** * Invoked when the mouse has been clicked on a component. */ @Override public void mouseClicked(MouseEvent e) { super.mouseClicked(e); Object o = graph.getFirstCellForLocation(e.getX(), e.getY()); if (o != null && o instanceof VGraphCell) { VGraphCell cell = (VGraphCell) o; o = cell.getUserObject(); if (o != null && o instanceof VChartPanel) { VChartPanel chart = (VChartPanel) o; if (SwingUtilities.isRightMouseButton(e)) { JPopupMenu menu = chart.createPopupMenu(true, true, true, true); menu.show(graph, e.getX(), e.getY()); } /* for (MouseListener l : chart.getMouseListeners()) { System.out.println("LISTENS CLI"); l.mouseClicked(e); } */ } } } /* // Event may be null when called to cancel the current operation. @Override public void mouseReleased(MouseEvent e) { super.mouseReleased(e); Object[] cells = graphSelectionModel.getSelectionCells(); Rectangle2D bounds = graph.getCellBounds(cells); if (bounds != null) { Rectangle2D b2 = graph.toScreen((Rectangle2D) bounds.clone()); graph.scrollRectToVisible(new Rectangle((int) b2.getX(), (int) b2.getY(), (int) b2.getWidth(), (int) b2.getHeight())); } } */ /** * Invoked when the mouse pointer has been moved on a component (with no * buttons down). */ @Override public void mouseMoved(MouseEvent e) { if (graph.isMoveable()) { super.mouseMoved(e); } Object o = graph.getFirstCellForLocation(e.getX(), e.getY()); if (o != null && o instanceof VGraphCell) { selectedCell = (VGraphCell) o; Rectangle2D bounds = graph.getCellBounds(selectedCell); menu.show(graph, (int) (bounds.getX() + bounds.getWidth()), (int) bounds.getY() + (int) (bounds.getHeight() - menu.getHeight())); } } }; }
From source file:net.itransformers.topologyviewer.gui.GraphViewerPanel.java
private AbstractModalGraphMouse createModalGraphMouse() { final AbstractModalGraphMouse graphMouse = new DefaultModalGraphMouse<String, String>(); graphMouse.add(new AbstractPopupGraphMousePlugin() { @Override// w ww . j a v a 2s .c om protected void handlePopup(final MouseEvent e) { GraphElementAccessor<String, String> pickSupport = vv.getPickSupport(); // final String v = pickSupport.getVertex(vv.getGraphLayout(), e.getX(), e.getY()); Collection<String> picked = new HashSet(getPickedVerteces()); final String[] varr = picked.toArray(new String[picked.size()]); final java.util.List<RightClickItemType> rightClickItem = GraphViewerPanel.this.viewerConfig .getRightClickItem(); JPopupMenu popup = new JPopupMenu(); fillRightClickMenu(varr, rightClickItem, popup); JMenuItem remove = new JMenuItem("remove"); popup.add(remove); remove.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { for (String v : varr) { currentGraph.removeVertex(v); } vv.repaint(); } }); popup.show(vv, e.getX(), e.getY()); } }); return graphMouse; }
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();//from w w w.ja va 2 s. co 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:gdt.jgui.entity.folder.JFolderFacetOpenItem.java
/** * Get the popup menu for the child node of the facet node * in the digest view./*ww w . j a va 2 s .c om*/ * @return the popup menu. */ @Override public JPopupMenu getPopupMenu(final String digestLocator$) { JPopupMenu popup = new JPopupMenu(); try { Properties locator = Locator.toProperties(digestLocator$); final String encodedSelection$ = locator.getProperty(JEntityDigestDisplay.SELECTION); byte[] ba = Base64.decodeBase64(encodedSelection$); final String selection$ = new String(ba, "UTF-8"); // System.out.println("JFolderFacetOpenItem:getPopupMenu:selection:="+selection$); locator = Locator.toProperties(selection$); String nodeType$ = locator.getProperty(JEntityDigestDisplay.NODE_TYPE); if (JEntityDigestDisplay.NODE_TYPE_FACET_OWNER.equals(nodeType$)) { JMenuItem openItem = new JMenuItem("Open"); popup.add(openItem); openItem.setHorizontalTextPosition(JMenuItem.RIGHT); openItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { Properties locator = Locator.toProperties(selection$); String entihome$ = locator.getProperty(Entigrator.ENTIHOME); String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY); File file = new File(entihome$ + "/" + entityKey$); Desktop.getDesktop().open(file); } catch (Exception ee) { Logger.getLogger(JFieldsFacetOpenItem.class.getName()).info(ee.toString()); } } }); JMenuItem editItem = new JMenuItem("Edit"); popup.add(editItem); editItem.setHorizontalTextPosition(JMenuItem.RIGHT); editItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { Properties locator = Locator.toProperties(selection$); String entihome$ = locator.getProperty(Entigrator.ENTIHOME); String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY); JFolderPanel fp = new JFolderPanel(); String fpLocator$ = fp.getLocator(); fpLocator$ = Locator.append(fpLocator$, Entigrator.ENTIHOME, entihome$); fpLocator$ = Locator.append(fpLocator$, EntityHandler.ENTITY_KEY, entityKey$); JConsoleHandler.execute(console, fpLocator$); } catch (Exception ee) { Logger.getLogger(JFieldsFacetOpenItem.class.getName()).info(ee.toString()); } } }); } if (NODE_TYPE_FILE_NODE.equals(nodeType$)) { JMenuItem openItem = new JMenuItem("Open"); popup.add(openItem); openItem.setHorizontalTextPosition(JMenuItem.RIGHT); openItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { Properties locator = Locator.toProperties(selection$); String filePath$ = locator.getProperty(JFolderPanel.FILE_PATH); File file = new File(filePath$); Desktop.getDesktop().open(file); } catch (Exception ee) { Logger.getLogger(JFieldsFacetOpenItem.class.getName()).info(ee.toString()); } } }); String filePath$ = locator.getProperty(JFolderPanel.FILE_PATH); final File file = new File(filePath$); if (isTextFile(file)) { JMenuItem editItem = new JMenuItem("Edit"); popup.add(editItem); editItem.setHorizontalTextPosition(JMenuItem.RIGHT); editItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { InputStream is = new FileInputStream(file); ByteArrayOutputStream bos = new ByteArrayOutputStream(); byte[] b = new byte[1024]; int bytesRead = 0; while ((bytesRead = is.read(b)) != -1) { bos.write(b, 0, bytesRead); } byte[] ba = bos.toByteArray(); is.close(); String text$ = new String(ba, "UTF-8"); JTextEditor te = new JTextEditor(); String teLocator$ = te.getLocator(); teLocator$ = Locator.append(teLocator$, Entigrator.ENTIHOME, entihome$); teLocator$ = Locator.append(teLocator$, JTextEditor.TEXT, text$); locator$ = Locator.append(locator$, JRequester.REQUESTER_ACTION, JFolderPanel.ACTION_EDIT_FILE); locator$ = Locator.append(locator$, JFolderPanel.FILE_PATH, file.getPath()); locator$ = Locator.append(locator$, BaseHandler.HANDLER_METHOD, "response"); locator$ = Locator.append(locator$, JEntityDigestDisplay.SELECTION, encodedSelection$); String requesterResponceLocator$ = Locator.compressText(locator$); teLocator$ = Locator.append(teLocator$, JRequester.REQUESTER_RESPONSE_LOCATOR, requesterResponceLocator$); JConsoleHandler.execute(console, teLocator$); } catch (Exception ee) { Logger.getLogger(getClass().getName()).info(ee.toString()); } } }); } } return popup; } catch (Exception e) { Logger.getLogger(getClass().getName()).severe(e.toString()); return null; } }
From source file:org.eurocarbdb.application.glycoworkbench.plugin.SpectraPanel.java
private JPopupMenu createPopupMenu(boolean over_peak) { JPopupMenu menu = new JPopupMenu(); if (over_peak) { updatePeakActions();/*w ww.ja v a 2 s .co m*/ menu.add(theActionManager.get("addpeaks")); ButtonGroup group = new ButtonGroup(); if (shown_mslevel.equals("ms")) { for (GlycanAction a : theApplication.getPluginManager().getMsPeakActions()) { JRadioButtonMenuItem last = new JRadioButtonMenuItem( new GlycanAction(a, "annotatepeaks", -1, "", this)); menu.add(last); last.setSelected(a == ms_action); group.add(last); } } else { for (GlycanAction a : theApplication.getPluginManager().getMsMsPeakActions()) { JRadioButtonMenuItem last = new JRadioButtonMenuItem( new GlycanAction(a, "annotatepeaks", -1, "", this)); menu.add(last); last.setSelected(a == msms_action); group.add(last); } } menu.addSeparator(); } menu.add(theActionManager.get("zoomnone")); menu.add(theActionManager.get("zoomin")); menu.add(theActionManager.get("zoomout")); return menu; }
From source file:edu.ku.brc.af.ui.forms.ResultSetController.java
/** * /* ww w .ja v a2s. c o m*/ */ protected JPopupMenu createPopupMenu() { JPopupMenu popupMenu = new JPopupMenu(); JMenuItem mi = UIHelper.createLocalizedMenuItem("Go to Record", null, null, true, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { showGotoRecDlg(); } }); popupMenu.add(mi); return popupMenu; }
From source file:ca.phon.app.project.ProjectWindow.java
/** * Displays the session list menu//w w w . ja va2 s . 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); }