List of usage examples for javax.swing JPopupMenu add
public JMenuItem add(Action a)
Action
object. From source file:com.haulmont.cuba.desktop.gui.components.DesktopAbstractTable.java
protected JPopupMenu createPopupMenu() { JPopupMenu popup = new JPopupMenu(); JMenuItem menuItem;//from w w w . j av a 2 s . c om for (final Action action : actionList) { if (StringUtils.isNotBlank(action.getCaption()) && action.isVisible()) { menuItem = new JMenuItem(action.getCaption()); if (action.getIcon() != null) { menuItem.setIcon(AppBeans.get(IconResolver.class).getIconResource(action.getIcon())); } if (action.getShortcutCombination() != null) { menuItem.setAccelerator(convertKeyCombination(action.getShortcutCombination())); } menuItem.setEnabled(action.isEnabled()); menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { action.actionPerform(DesktopAbstractTable.this); } }); popup.add(menuItem); } } return popup; }
From source file:corelyzer.ui.CorelyzerApp.java
private JPopupMenu sectionListPopupMenu(final int[] rows) { // section popup JPopupMenu menu = new JPopupMenu("Sections"); // Section/Image property JMenuItem propertiesMenuItem = new JMenuItem("Properties..."); propertiesMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, MENU_MASK)); propertiesMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { controller.sectionProperties(rows); }//from w w w . j a v a 2s .c o m }); JMenuItem splitMenuItem = new JMenuItem("Split..."); if (rows.length > 1) { splitMenuItem.setEnabled(false); } splitMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { controller.sectionSplit(); } }); JMenuItem deleteMenuItem = new JMenuItem("Delete"); deleteMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { onDeleteSelectedSections(rows); } }); JMenuItem locateMenuItem = new JMenuItem("Locate"); locateMenuItem.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { onLocateSelectedSection(); } }); menu.add(locateMenuItem); menu.add(splitMenuItem); menu.add(propertiesMenuItem); menu.add(deleteMenuItem); return menu; }
From source file:edu.harvard.i2b2.patientSet.ui.PatientSetJPanel.java
private void createPopupMenu() { JMenuItem menuItem;//from w ww .j ava 2 s . co m // Create the popup menu. JPopupMenu popup = new JPopupMenu(); menuItem = new JMenuItem("Rename ..."); // menuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke( // java.awt.event.KeyEvent.VK_R, // java.awt.event.InputEvent.CTRL_MASK)); menuItem.addActionListener(this); popup.add(menuItem); /* popup.add(new javax.swing.JSeparator()); */ menuItem = new JMenuItem("Delete"); // menuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke( // java.awt.event.KeyEvent.VK_D, // java.awt.event.InputEvent.CTRL_MASK)); menuItem.addActionListener(this); popup.add(menuItem); popup.add(new javax.swing.JSeparator()); menuItem = new JMenuItem("Refresh All"); // menuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke( // java.awt.event.KeyEvent.VK_A, // java.awt.event.InputEvent.CTRL_MASK)); menuItem.addActionListener(this); popup.add(menuItem); menuItem = new JMenuItem("Cancel"); // menuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke( // java.awt.event.KeyEvent.VK_C, // java.awt.event.InputEvent.CTRL_MASK)); menuItem.addActionListener(this); popup.add(menuItem); // Add listener to the tree MouseListener popupListener = new PreviousRunsTreePopupListener(popup); jTree1.addMouseListener(popupListener); jTree1.addMouseMotionListener(new PreviousRunsTreeMouseMoveListener()); }
From source file:net.minelord.gui.panes.IRCPane.java
public void connected() { SwingUtilities.invokeLater(new Runnable() { @Override/*from w w w.j a v a2 s .co m*/ public void run() { scroller.setBounds(scrollerWithoutTopicWithUserlist); scroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); status = "Connected"; client.connectAlertListener(); TitledBorder title = BorderFactory .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Connected"); title.setTitleJustification(TitledBorder.RIGHT); userList = new JList(client.getUserList().toArray()); userScroller = new JScrollPane(userList); userScroller.setBounds(userScrollerWithoutTopic); userList.setBounds(0, 0, 210, 250); userList.setBackground(Color.gray); userList.setForeground(Color.gray.darker().darker().darker()); userScroller.setBorder(title); userScroller.getVerticalScrollBar().setUnitIncrement(5); scroller.setBorder(BorderFactory .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "")); if (client.getTopic().trim().length() > 0) { topic = new JLabel(client.getTopic()); scroller.setBounds(scrollerWithTopicWithUserlist); userScroller.setBounds(userScrollWithTopic); userList.setBounds(0, 0, 210, 225); title = BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Topic set by " + client.getTopicSetter()); title.setTitleJustification(TitledBorder.LEFT); topic.setBorder(title); topic.setBounds(topicBounds); add(topic); } else topic = new JLabel(""); input.setEnabled(true); input.requestFocus(); final JPopupMenu userPopup = new JPopupMenu(); JLabel breakLine = new JLabel("____"); JLabel help = new JLabel("Politely ask for help"); JLabel message = new JLabel("Message"); JLabel sortNormal = new JLabel("Normal"); JLabel sortAlphabetical = new JLabel("Alphabetical"); JLabel sortRoles = new JLabel("Roles"); help.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { userPopup.setVisible(false); sendMessage("/me kicks " + userList.getModel().getElementAt(userList.getSelectedIndex()) + " in the shins"); sendMessage("I need help you pleb"); } public void mouseReleased(MouseEvent e) { } }); message.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent paramMouseEvent) { userPopup.setVisible(false); input.setText("/msg " + userList.getModel().getElementAt(userList.getSelectedIndex()) + (input.getText().length() > 0 && input.getText().charAt(0) == ' ' ? input.getText() : " " + input.getText())); input.select(0, ("/msg " + userList.getModel().getElementAt(userList.getSelectedIndex()) + (input.getText().length() > 0 && input.getText().charAt(0) == ' ' ? "" : " ")) .length()); input.requestFocus(); } }); sortNormal.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent paramMouseEvent) { userPopup.setVisible(false); updateUserList(0); } }); sortAlphabetical.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent paramMouseEvent) { userPopup.setVisible(false); updateUserList(1); } }); sortRoles.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent paramMouseEvent) { userPopup.setVisible(false); updateUserList(2); } }); userPopup.add(help); userPopup.add(message); userPopup.add(breakLine); userPopup.add(sortNormal); userPopup.add(sortAlphabetical); userPopup.add(sortRoles); userList.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { check(e); } public void mouseReleased(MouseEvent e) { check(e); } public void check(MouseEvent e) { userList.setSelectedIndex(userList.locationToIndex(e.getPoint())); userPopup.show(userList, e.getX(), e.getY()); } }); add(userScroller); final JPopupMenu textPopup = new JPopupMenu(); JLabel copy = new JLabel("Copy"); copy.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent paramMouseEvent) { textPopup.setVisible(false); if (text.getSelectedText() != null && text.getSelectedText().length() != 0) { StringSelection selection = new StringSelection(text.getSelectedText()); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); clipboard.setContents(selection, selection); } } }); textPopup.add(copy); text.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent e) { if (SwingUtilities.isRightMouseButton(e)) textPopup.show(text, e.getX(), e.getY()); } }); add(userScroller); repaint(); } }); }
From source file:gda.plots.SimplePlot.java
private void addHistoryCommandsToPopupMenu() { JPopupMenu jpm = getPopupMenu(); jpm.add(new JSeparator()); // New button to allow user to add current plot to stored plots // This history mechanism assumes that there is only one line being plotted // and this line is stored in the last entry of seriesStore that was not in history addLine = new JMenuItem("Add current line to history"); addLine.addActionListener(new ActionListener() { @Override/*from ww w. j a v a 2 s . co m*/ public void actionPerformed(ActionEvent e) { SimpleXYSeries s = findLine(lastLineAdded - history.size()); if (s != null) { history.addFirst(s); if (history.size() > HMAX) { history.removeLast(); } } } }); jpm.add(addLine); // New button to allow user to remove first plot from stored plots removeFirst = new JMenuItem("Remove most recent line from history"); removeFirst.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { historyRemoveFirst(); } }); jpm.add(removeFirst); // New button to allow user to remove last plot from stored plots removeLast = new JMenuItem("Remove oldest line from history"); removeLast.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { historyRemoveLast(); } }); jpm.add(removeLast); // New button to allow user to add current plot to stored plots clearLines = new JMenuItem("Clear history"); clearLines.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { historyClear(); } }); jpm.add(clearLines); }
From source file:com.github.dougkelly88.FLIMPlateReaderGUI.SequencingClasses.GUIComponents.XYSequencing.java
private void setControlDefaults() { pmdp_ = new PlateMapDrawPanel(this); sap_ = SeqAcqProps.getInstance();//from w w w .j av a 2 s . c o m plateMapBasePanel.setLayout(new BorderLayout()); plateMapBasePanel.add(pmdp_, BorderLayout.CENTER); tableModel_ = new FOVTableModel(pp_); searchFOVtableModel_ = new FOVTableModel(pp_); //Not sure if this is the best way, but try it for now. tableModel_.addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { } }); fovTable_ = new JTable(); fovTable_.setModel(tableModel_); fovTable_.setSurrendersFocusOnKeystroke(true); fovTable_.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); JScrollPane scroller = new javax.swing.JScrollPane(fovTable_); fovTable_.setPreferredScrollableViewportSize(new java.awt.Dimension(190, 130)); fovTablePanel.setLayout(new BorderLayout()); fovTablePanel.add(scroller, BorderLayout.CENTER); final JPopupMenu popupMenu = new JPopupMenu(); JMenuItem deleteItem = new JMenuItem("Delete FOV"); deleteItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int r = fovTable_.getSelectedRow(); tableModel_.removeRow(r); } }); JMenuItem addItem = new JMenuItem("Add FOV"); addItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int r = fovTable_.getSelectedRow(); tableModel_.insertRow(r, new FOV("A1", pp_, 6000)); } }); JMenuItem goToFOVItem = new JMenuItem("Go to FOV"); goToFOVItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int r = fovTable_.getSelectedRow(); // FOV fov = tableModel_.getData().get(r); xyzmi_.gotoFOV(tableModel_.getData().get(r)); if (!zAsOffset_) { double zval = tableModel_.getData().get(r).getZ(); xyzmi_.moveZAbsolute(zval); } else { // obviously, this isn't quite right - we want to get // the offset of the CURRENT FOV (perhaps from parent in // later implementations?) and subtract from that of the // NEWLY SELECTED FOV. // TODO: fix for proper zAsOffset behaviour. // Wait for move completion while (xyzmi_.isStageBusy()) { System.out.println("Stage moving..."); } ; if (parent_.checkifAFenabled()) { // If we have gone to the FOV, and have AF, do AF xyzmi_.customAutofocus(parent_.getAFOffset()); } else { // If we don't have AF, go to the 'good offset position' xyzmi_.moveZAbsolute(parent_.getFixedAFDefault()); } //Now do the relative shift xyzmi_.moveZRelative(tableModel_.getData().get(r).getZ()); System.out.println("Z value" + tableModel_.getData().get(r).getZ()); } } }); popupMenu.add(addItem); popupMenu.add(deleteItem); popupMenu.add(goToFOVItem); fovTable_.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { // System.out.println("pressed"); } @Override public void mouseReleased(MouseEvent e) { if (e.isPopupTrigger()) { JTable source = (JTable) e.getSource(); int row = source.rowAtPoint(e.getPoint()); int column = source.columnAtPoint(e.getPoint()); if (!source.isRowSelected(row)) { source.changeSelection(row, column, false, false); } popupMenu.show(e.getComponent(), e.getX(), e.getY()); } } }); // fovTable_.setDefaultRenderer(FOV.class, new TableRenderer()); setupInsertComboBox(); }
From source file:gda.plots.SimplePlot.java
/** * Creates the JPopupMenu, overrides (but uses) the super class method adding items for the Magnification and * Logarithmic axes.//from ww w . j a v a2 s . co m * * @param properties * boolean if true appears on menu * @param save * boolean if true appears on menu * @param print * boolean if true appears on menu * @param zoom * boolean if true appears on menu * @return the popup menu */ @Override protected JPopupMenu createPopupMenu(boolean properties, boolean save, boolean print, boolean zoom) { // Create the popup without the zooming parts JPopupMenu jpm = super.createPopupMenu(properties, false, print, false); // as the save function on the chartpanel doesn't remember its location, // we shall remove it and and create a new save option if (save) { jpm.add(new JSeparator()); // The save button saveButton = new JMenuItem("Save As"); saveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { saveAs(); } }); jpm.add(saveButton); } jpm.add(new JSeparator()); // This button toggles the data-type magnification magnifyDataButton = new JCheckBoxMenuItem("Magnify(Data)"); magnifyDataButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setMagnifyingData(!isMagnifyingData()); } }); jpm.add(magnifyDataButton); jpm.add(new JSeparator()); // The zoomButton toggles the value of zooming. zoomButton = new JCheckBoxMenuItem("Zoom"); zoomButton.setHorizontalTextPosition(SwingConstants.LEFT); zoomButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setZooming(!isZooming()); } }); jpm.add(zoomButton); // The unZoomButton is not a toggle, it undoes the last zoom. unZoomButton = new JMenuItem("UnZoom"); unZoomButton.setEnabled(false); unZoomButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { unZoom(); } }); jpm.add(unZoomButton); if (type == LINECHART) { jpm.add(new JSeparator()); turboModeButton = new JCheckBoxMenuItem("Turbo Mode"); turboModeButton.setHorizontalTextPosition(SwingConstants.LEFT); turboModeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setTurboMode(!isTurboMode()); } }); turboModeButton.setSelected(isTurboMode()); jpm.add(turboModeButton); stripModeButton = new JCheckBoxMenuItem("StripChart Mode"); stripModeButton.setHorizontalTextPosition(SwingConstants.LEFT); stripModeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String widthStr = ""; { double width = lastDomainBoundsLeft != null ? lastDomainBoundsLeft.getLength() : Double.MAX_VALUE; widthStr = getXAxisNumberFormat().format(width); widthStr = JOptionPane.showInputDialog(null, "Enter the x strip width - clear for autorange", widthStr); if (widthStr == null) //cancel return; } Double newStripWidth = null; if (!widthStr.isEmpty()) { try { newStripWidth = Double.valueOf(widthStr); } catch (Exception ex) { logger.error(ex.getMessage(), ex); } } setStripWidth(newStripWidth); } }); stripModeButton.setSelected(isStripMode()); jpm.add(stripModeButton); xLimitsButton = new JCheckBoxMenuItem("Fix X Axis Limits"); xLimitsButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String minStr = ""; { double min = lastDomainBoundsLeft != null ? lastDomainBoundsLeft.getLowerBound() : Double.MAX_VALUE; minStr = getXAxisNumberFormat().format(min); minStr = JOptionPane.showInputDialog(null, "Enter the min x value - clear for autorange", minStr); if (minStr == null) //cancel return; } String maxStr = ""; if (!minStr.isEmpty()) { double max = lastDomainBoundsLeft != null ? lastDomainBoundsLeft.getUpperBound() : -Double.MAX_VALUE; maxStr = getXAxisNumberFormat().format(max); maxStr = JOptionPane.showInputDialog(null, "Enter the max x value - clear for autorange", maxStr); if (maxStr == null) //cancel return; } Range newBounds = null; if (!maxStr.isEmpty() && !minStr.isEmpty()) { try { newBounds = new Range(Double.valueOf(minStr), Double.valueOf(maxStr)); } catch (Exception ex) { logger.error(ex.getMessage(), ex); } } setDomainBounds(newBounds); } }); xLimitsButton.setSelected(false); jpm.add(xLimitsButton); } jpm.add(new JSeparator()); xLogLinButton = new JMenuItem("Logarithmic X axis"); xLogLinButton.setEnabled(true); xLogLinButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setXAxisLogarithmic(!isXAxisLogarithmic()); } }); jpm.add(xLogLinButton); yLogLinButton = new JMenuItem("Logarithmic Y axis"); yLogLinButton.setEnabled(true); yLogLinButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setYAxisLogarithmic(!isYAxisLogarithmic()); } }); jpm.add(yLogLinButton); y2LogLinButton = new JMenuItem("Logarithmic Y2 axis"); y2LogLinButton.setEnabled(false); y2LogLinButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setYAxisTwoLogarithmic(!isYAxisTwoLogarithmic()); } }); jpm.add(y2LogLinButton); jpm.add(new JSeparator()); // Adding a new button to allow the user to select the formatting they // want on the x and y axis xFormatButton = new JMenuItem("X Axis Format"); xFormatButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String Format = getXAxisNumberFormat().format(0.0); String input = JOptionPane.showInputDialog(null, "Enter the new formatting for the X axis, of the form 0.0000E00", Format); // try forcing this into some objects try { setScientificXAxis(new DecimalFormat(input)); } catch (Exception err) { logger.error("Could not use this format due to {}", e); } } }); jpm.add(xFormatButton); // Adding a new button to allow the user to select the formatting they // want on the x and y axis yFormatButton = new JMenuItem("Y Axis Format"); yFormatButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String Format = getYAxisNumberFormat().format(0.0); String input = JOptionPane.showInputDialog(null, "Enter the new formatting for the Y axis, of the form 0.0000E00", Format); // try forcing this into some objects try { setScientificYAxis(new DecimalFormat(input)); } catch (Exception err) { logger.error("Could not use this format due to {}", e); } } }); jpm.add(yFormatButton); // The zoomButton toggles the value of zooming. xAxisVerticalTicksButton = new JCheckBoxMenuItem("Vertical X Ticks"); xAxisVerticalTicksButton.setHorizontalTextPosition(SwingConstants.LEFT); xAxisVerticalTicksButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setVerticalXAxisTicks(xAxisVerticalTicksButton.isSelected()); } }); jpm.add(xAxisVerticalTicksButton); return jpm; }
From source file:org.gumtree.vis.awt.JChartPanel.java
@Override protected JPopupMenu createPopupMenu(boolean properties, boolean copy, boolean save, boolean print, boolean zoom) { JPopupMenu menu = super.createPopupMenu(properties, copy, save, print, zoom); this.markerManagementMenu = new JMenu("Marker Management"); this.internalMarkerMenuItem = new JMenuItem("Add Cross Marker Here"); internalMarkerMenuItem.setActionCommand(ADD_INTERNAL_MARKER_COMMAND); internalMarkerMenuItem.addActionListener(this); this.horizontalBarMenuItem = new JMenuItem("Add Horizontal Bar"); horizontalBarMenuItem.setActionCommand(ADD_HORIZONTAL_BAR_COMMAND); horizontalBarMenuItem.addActionListener(this); this.verticalBarMenuItem = new JMenuItem("Add Vertical Bar"); verticalBarMenuItem.setActionCommand(ADD_VERTICAL_BAR_COMMAND); verticalBarMenuItem.addActionListener(this); this.removeSelectedMarkerMenuItem = new JMenuItem("Remove Selected Marker"); removeSelectedMarkerMenuItem.setActionCommand(REMOVE_SELECTED_MARKER_COMMAND); removeSelectedMarkerMenuItem.addActionListener(this); this.clearMarkersMenuItem = new JMenuItem("Clear Cross Markers"); clearMarkersMenuItem.setActionCommand(CLEAR_INTERNAL_MARKERS_COMMAND); clearMarkersMenuItem.addActionListener(this); this.clearDomainMarkersMenuItem = new JMenuItem("Clear Vertical Markers"); clearDomainMarkersMenuItem.setActionCommand(CLEAR_DOMAIN_MARKERS_COMMAND); clearDomainMarkersMenuItem.addActionListener(this); this.clearRangeMarkersMenuItem = new JMenuItem("Clear Horizontal Markers"); clearRangeMarkersMenuItem.setActionCommand(CLEAR_RANGE_MARKERS_COMMAND); clearRangeMarkersMenuItem.addActionListener(this); this.clearAllMarkersMenuItem = new JMenuItem("Clear All Markers"); clearAllMarkersMenuItem.setActionCommand(CLEAR_ALL_MARKERS_COMMAND); clearAllMarkersMenuItem.addActionListener(this); markerManagementMenu.add(removeSelectedMarkerMenuItem); markerManagementMenu.addSeparator(); markerManagementMenu.add(internalMarkerMenuItem); markerManagementMenu.add(clearMarkersMenuItem); markerManagementMenu.addSeparator(); markerManagementMenu.add(horizontalBarMenuItem); markerManagementMenu.add(clearRangeMarkersMenuItem); markerManagementMenu.addSeparator(); markerManagementMenu.add(verticalBarMenuItem); markerManagementMenu.add(clearDomainMarkersMenuItem); markerManagementMenu.addSeparator(); markerManagementMenu.add(clearAllMarkersMenuItem); menu.addSeparator();// w ww . ja v a 2s .c om menu.add(markerManagementMenu); this.removeSelectedMaskMenuItem = new JMenuItem(); this.removeSelectedMaskMenuItem.setActionCommand(REMOVE_SELECTED_MASK_COMMAND); this.removeSelectedMaskMenuItem.addActionListener(this); menu.addSeparator(); menu.add(removeSelectedMaskMenuItem); maskManagementMenu = new JMenu("Mask Management"); menu.add(maskManagementMenu); return menu; }
From source file:com.mirth.connect.client.ui.Frame.java
/** * Initializes the bound method call for the task pane actions and adds them to the * taskpane/popupmenu.// w ww. ja va2 s. c om */ public int addTask(String callbackMethod, String displayName, String toolTip, String shortcutKey, ImageIcon icon, JXTaskPane pane, JPopupMenu menu, Object handler) { BoundAction boundAction = ActionFactory.createBoundAction(callbackMethod, displayName, shortcutKey); if (icon != null) { boundAction.putValue(Action.SMALL_ICON, icon); } boundAction.putValue(Action.SHORT_DESCRIPTION, toolTip); boundAction.registerCallback(handler, callbackMethod); Component component = pane.add(boundAction); getComponentTaskMap().put(component, callbackMethod); if (menu != null) { menu.add(boundAction); } return (pane.getContentPane().getComponentCount() - 1); }
From source file:edu.ku.brc.af.ui.forms.FormViewObj.java
/** * Shows Parent Form's Context Menu./*from w w w . j a v a 2s . c o m*/ * @param e the mouse event */ protected void showContextMenu(MouseEvent e) { if (e.isPopupTrigger() && mvParent != null && mvParent.isTopLevel() && isEditing) { JPopupMenu popup = new JPopupMenu(); JMenuItem menuItem = new JMenuItem(UIRegistry.getResourceString("CONFIG_CARRY_FORWARD_MENU")); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ex) { configureCarryForward(); } }); popup.add(menuItem); JCheckBoxMenuItem chkMI = new JCheckBoxMenuItem( UIRegistry.getResourceString("CARRY_FORWARD_CHECKED_MENU")); chkMI.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ex) { toggleCarryForward(); } }); chkMI.setSelected(isCarryForwardConfgured() && isDoCarryForward()); chkMI.setEnabled(isCarryForwardConfgured()); popup.add(chkMI); popup.addSeparator(); chkMI = new JCheckBoxMenuItem(UIRegistry.getAction(AUTO_NUM)); /*chkMI.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ex) { toggleAutoNumberOnOffState(); } });*/ chkMI.setSelected(isAutoNumberOn); popup.add(chkMI); popup.show(e.getComponent(), e.getX(), e.getY()); } }