/** * Creates a new feedback nag. * * @param iconManager The icon manager to use to find the feedback nag icon. * @param feedbackDialogProvider Provider of feedback dialogs. * @param eventBus The event bus to post messages to */ @Inject public FeedbackNag( final IconManager iconManager, final DialogProvider<FeedbackDialog> feedbackDialogProvider, final EventBus eventBus) { this.feedbackDialogProvider = feedbackDialogProvider; this.eventBus = eventBus; menu = new JPopupMenu(); show = new JMenuItem("Open"); final JMenuItem dismiss = new JMenuItem("Dismiss"); setIcon(iconManager.getIcon("feedback")); setBorder(BorderFactory.createEtchedBorder()); setToolTipText("We would appreciate any feedback you may have about " + "DMDirc."); menu.add(show); menu.add(dismiss); show.addActionListener(this); dismiss.addActionListener(this); addMouseListener(this); // TODO: There should be some other class which adds the nag to the status bar eventBus.publishAsync(new StatusBarComponentAddedEvent(this)); }
private void createPopup(JPopupMenu popup) { ActionListener al = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand().trim(); if (cmd.equalsIgnoreCase("play")) { player.play(); } else if (cmd.equalsIgnoreCase("pause")) { player.pause(); } else if (cmd.equalsIgnoreCase("next")) { player.next(); } else if (cmd.equalsIgnoreCase("previous")) { player.prev(); } else if (cmd.equalsIgnoreCase("stop")) { player.stop(); } else if (cmd.equalsIgnoreCase("quit")) { app.exit(); } } }; popup.add(" Play").addActionListener(al); popup.add(" Pause").addActionListener(al); popup.add(" Next").addActionListener(al); popup.add(" Stop").addActionListener(al); popup.add(" Previous ").addActionListener(al); popup.add(" Quit").addActionListener(al); }
/** Adds a pop up menu. */ private void addPopupMenu() { final JPopupMenu popup = new JPopupMenu(); JMenuItem menuItem = Utilities.createMenuItem(INFO_CTRL_PANEL_NEW_INDEX_MENU.get()); menuItem.addActionListener( new ActionListener() { /** {@inheritDoc} */ public void actionPerformed(ActionEvent ev) { newIndexClicked(); } }); popup.add(menuItem); menuItem = Utilities.createMenuItem(INFO_CTRL_PANEL_NEW_VLV_INDEX_MENU.get()); menuItem.addActionListener( new ActionListener() { /** {@inheritDoc} */ public void actionPerformed(ActionEvent ev) { newVLVIndexClicked(); } }); popup.add(menuItem); popup.add(new JSeparator()); deleteMenuItem = Utilities.createMenuItem(INFO_CTRL_PANEL_DELETE_INDEX_MENU.get()); deleteMenuItem.addActionListener( new ActionListener() { /** {@inheritDoc} */ public void actionPerformed(ActionEvent ev) { deleteClicked(); } }); popup.add(deleteMenuItem); deleteMenuItem.setEnabled(false); ((CustomTree) treePane.getTree()).setPopupMenu(popup); }
/** * Shows the PopUp * * @param e MouseEvent */ protected void showPopUpMenu(MouseEvent e) { if (!(e.getSource() instanceof JList)) { return; } JList list = (JList) e.getSource(); int i = list.locationToIndex(e.getPoint()); list.setSelectedIndex(i); JPopupMenu menu = new JPopupMenu(); Rating selRating = (Rating) list.getSelectedValue(); JMenuItem item = new JMenuItem(mLocalizer.msg("showDetails", "Show Details")); item.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { view(); } }); item.setFont(item.getFont().deriveFont(Font.BOLD)); menu.add(item); menu.add(new ListAction(this, selRating.getTitle())); menu.add(new ShowDetailsAction(selRating.getRatingId())); menu.show(list, e.getX(), e.getY()); }
private void doPopup(MouseEvent e) { // Check if there is any thing is selected boolean isSelected = false; if (changedList != null) { if (changedList.getSelection().size() > 0) isSelected = true; } if (!isSelected && newList != null) { if (newList.getSelection().size() > 0) isSelected = true; } if (!isSelected && deleteInDBList != null) { if (deleteInDBList.getSelection().size() > 0) isSelected = true; } if (!isSelected && deleteList != null) if (deleteList.getSelection().size() > 0) isSelected = true; if (!isSelected && localHasMoreIEList != null) { if (localHasMoreIEList.getSelection().size() > 0) isSelected = true; } if (!isSelected) return; JPopupMenu popup = new JPopupMenu(); popup.add(updateFromDBAction); popup.add(commitToDBAction); popup.add(showComparisonAction); popup.add(clearRecordAction); JComponent comp = (JComponent) e.getSource(); popup.show(comp, e.getX(), e.getY()); }
private JPopupMenu createTablePopupMenu() { final JPopupMenu menu = new JPopupMenu(); menu.add( new AbstractAction("Copy Term") { @Override public void actionPerformed(ActionEvent e) { copyTermAtPoint(tablePopup.getLocation()); } }); menu.add( new AbstractAction("Paste Term") { @Override public void actionPerformed(ActionEvent e) { pasteTermAtPoint(tablePopup.getLocation()); } }); menu.add( new AbstractAction("Edit Post-composed Term") { @Override public void actionPerformed(ActionEvent e) { runPostCompositionForTermAtPoint(tablePopup.getLocation()); } }); return menu; }
private void addLexemePropertiesPopupMenu() { menuLexemeProperties = new JPopupMenu() { @Override public void show(Component c, int x, int y) { intLexemePropertiesPopup = leksēmuĪpašībuTabula.rowAtPoint(new Point(x, y)); super.show(c, x, y); } }; JMenuItem addLexemeProperty = new JMenuItem("Pievienot īpašību"); addLexemeProperty.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (intLexemePropertiesPopup >= 0 && intLexemePropertiesPopup < leksēmuĪpašībuTabula.getRowCount()) addLexemeProperty(); } }); JMenuItem deleteLexemeProperty = new JMenuItem("Dzēst īpašību"); deleteLexemeProperty.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (intLexemePropertiesPopup >= 0 && intLexemePropertiesPopup < leksēmuĪpašībuTabula.getRowCount()) deleteLexemeProperty(intLexemePropertiesPopup); } }); menuLexemeProperties.add(addLexemeProperty); menuLexemeProperties.add(deleteLexemeProperty); leksēmuĪpašībuTabula.setComponentPopupMenu(menuLexemeProperties); }
void initControls() { JMenuItem jmi; jmi = new JMenuItem("JImage Menu"); jmi.setEnabled(false); popupMenu.add(jmi); jmi = new JMenuItem("Fit"); jmi.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { fit = true; repaint(); } }); popupMenu.add(jmi); JMenu scaleMenu = new JMenu("Set Scale"); popupMenu.add(scaleMenu); int scales[] = new int[] {25, 50, 100, 200, 400, 800}; for (int i = 0; i < scales.length; i++) { jmi = new JMenuItem(scales[i] + " %"); jmi.addActionListener(new ScaleAction(scales[i])); scaleMenu.add(jmi); } MyListener l = new MyListener(); addMouseMotionListener(l); addMouseListener(l); addMouseWheelListener(l); addKeyListener(l); }
private JPopupMenu fillMenu(boolean under) { final JPopupMenu result = new JBPopupMenu(); if (under && myOptions.length > 0) { final JMenuItem mainAction = new JBMenuItem(getAction()); configureItem(getMenuInfo(getAction()), mainAction); result.add(mainAction); result.addSeparator(); } for (Action each : myOptions) { if (getAction() == each) continue; final OptionInfo info = getMenuInfo(each); final JMenuItem eachItem = new JBMenuItem(each); configureItem(info, eachItem); result.add(eachItem); } if (!under && myOptions.length > 0) { result.addSeparator(); final JMenuItem mainAction = new JBMenuItem(getAction()); configureItem(getMenuInfo(getAction()), mainAction); result.add(mainAction); } return result; }
public Popup() { setLayout(new FlowLayout()); add(t); ActionListener al = new ActionListener() { public void actionPerformed(ActionEvent e) { t.setText(((JMenuItem) e.getSource()).getText()); } }; JMenuItem m = new JMenuItem("Hither"); m.addActionListener(al); popup.add(m); m = new JMenuItem("Yon"); m.addActionListener(al); popup.add(m); m = new JMenuItem("Afar"); m.addActionListener(al); popup.add(m); popup.addSeparator(); m = new JMenuItem("Stay Here"); m.addActionListener(al); popup.add(m); PopupListener pl = new PopupListener(); addMouseListener(pl); t.addMouseListener(pl); }
/** * Inserts the specified component into the menu at a given position. * * @param component the <code>Component</code> to insert * @param index specifies the position at which to insert the component, where 0 is the first * @exception IllegalArgumentException if <code>index</code> < 0 */ public void insert(Component component, int index) { if (index < 0) { throw new IllegalArgumentException("index less than zero."); } int nitems = getComponentCount(); // PENDING(ges): Why not use an array? Vector<Component> tempItems = new Vector<Component>(); /* Remove the item at index, nitems-index times storing them in a temporary vector in the order they appear on the menu. */ for (int i = index; i < nitems; i++) { tempItems.addElement(getComponent(index)); remove(index); } add(component); /* Add the removed items back to the menu, they are already in the correct order in the temp vector. */ for (Component tempItem : tempItems) { add(tempItem); } }
private void creerMenuContextuel() { menuActions = new JPopupMenu(); menuPlacer = new JMenu("Placer"); menuActions.add(menuPlacer); itemRetirer = new JMenuItem("Retirer"); menuActions.add(itemRetirer); itemPlacerNord = new JMenuItem("vers Nord"); menuPlacer.add(itemPlacerNord); itemPlacerEst = new JMenuItem("vers Est"); menuPlacer.add(itemPlacerEst); itemPlacerSud = new JMenuItem("vers Sud"); menuPlacer.add(itemPlacerSud); itemPlacerOuest = new JMenuItem("vers Ouest"); menuPlacer.add(itemPlacerOuest); menuOrienter = new JMenu("Orienter"); menuActions.add(menuOrienter); itemOrienterNord = new JMenuItem("vers Nord"); menuOrienter.add(itemOrienterNord); itemOrienterEst = new JMenuItem("vers Est"); menuOrienter.add(itemOrienterEst); itemOrienterSud = new JMenuItem("vers Sud"); menuOrienter.add(itemOrienterSud); itemOrienterOuest = new JMenuItem("vers Ouest"); menuOrienter.add(itemOrienterOuest); }
private void showSliderActions(MouseEvent evt, final int sliderIndex) { final JPopupMenu menu = new JidePopupMenu(); boolean showPopupMenu = false; JMenuItem menuItem; if (canChangeSliderCount()) { menuItem = createMenuItemAddNewSlider(sliderIndex, evt); if (menuItem != null) { menu.add(menuItem); showPopupMenu = true; } if (getSliderCount() > 2 && sliderIndex != INVALID_INDEX) { menuItem = createMenuItemDeleteSlider(sliderIndex); menu.add(menuItem); showPopupMenu = true; } } if (getSliderCount() > 2 && sliderIndex > 0 && sliderIndex < getSliderCount() - 1 && isSliderEditable(sliderIndex)) { menuItem = createMenuItemCenterSampleValue(sliderIndex); menu.add(menuItem); menuItem = createMenuItemCenterColorValue(sliderIndex); menu.add(menuItem); showPopupMenu = true; } if (showPopupMenu) { menu.show(evt.getComponent(), evt.getX(), evt.getY()); } }
/** * Statische Funktion welche das Popup f�r den Tabellenkopf erstellt und anzeigt. * * @param table Die Tabelle zu welcher das Popup geh�rt. * @param ctrl Ben�tigte Referenz zum GUI Controller * @param e Das MouseEvent welches das Popup �ffnet */ public static void createTableHeaderPopup(JTable table, ViewController ctrl, MouseEvent e) { createColumnCheckBoxes(ctrl); if (menuPopUp != null) { menuPopUp.setVisible(false); } menuPopUp = new JPopupMenu(); JMenu m_columns = new JMenu("Columns"); // $NON-NLS-1$ JMenuItem mi_hide = new JMenuItem(Messages.getString("PopUpMenu.1")); // $NON-NLS-1$ JMenuItem mi_showALL = new JMenuItem(Messages.getString("PopUpMenu.2")); // $NON-NLS-1$ selectedColumn = ctrl.getTable(ctrl.getSelectedTab()).getColumnModel().getColumnIndexAtX(e.getX()); if (ctrl.getUserInputData().getOriginalIndex(selectedColumn, ctrl.getSelectedTab()) == 0 || ctrl.getUserInputData().getOriginalIndex(selectedColumn, ctrl.getSelectedTab()) == 1) { mi_hide.setEnabled(false); } mi_hide.addActionListener(ctrl); mi_hide.setActionCommand("hide"); // $NON-NLS-1$ mi_showALL.addActionListener(ctrl); mi_showALL.setActionCommand("showall"); // $NON-NLS-1$ menuPopUp.add(mi_hide); menuPopUp.add(m_columns); for (int x = 0; x < columns.length; x++) { m_columns.add( columns[ctrl.getUserInputData().getColumnOrder(ctrl.getSelectedTab()).get(x).intValue()]); } menuPopUp.add(mi_showALL); menuPopUp.show(table.getTableHeader(), e.getX(), e.getY()); }
private JPopupMenu createPopupMenu() { JPopupMenu menu = new JPopupMenu(); menu.add(this.printAction); menu.add(this.copyPreviewAction); this.basePanel.ifPresent(p -> menu.add(p.frame().getSwitchPreviewAction())); return menu; }
public JPopupMenu getMultiRowSelectedPopupMenu() { JPopupMenu popupMenu = new JPopupMenu(); JMenuItem item0 = getMenuItme("核销(H)", 'H', "H"); popupMenu.add(item0); JMenuItem item1 = getMenuItme("撤销核销(C)", 'C', "C"); popupMenu.add(item1); List<NPczbInfo> list = this.getSelectedRowList(); boolean doHX = false; boolean noHX = false; for (NPczbInfo one : list) { if (null == one.ENUM_JSZT || one.ENUM_JSZT == NPczbEnum.ENUM_JSZT.BFHX.key) { doHX = true; // 核销 } else if (one.ENUM_JSZT == NPczbEnum.ENUM_JSZT.HX.key) { noHX = true; // 撤销核销 } } if (doHX && !noHX) { item0.setEnabled(true); item1.setEnabled(false); } else if (!doHX && noHX) { item0.setEnabled(false); item1.setEnabled(true); } else { item0.setEnabled(false); item1.setEnabled(false); } popupMenu.addSeparator(); popupMenu.add(getMenuItme("刷新(R)", 'R', "R")); return popupMenu; }
protected JPopupMenu createPopupMenu(SearchResultDataLine[] lines) { // do not return a menu if right-clicking on the dummy panel if (!isKillable()) return null; JPopupMenu menu = new SkinPopupMenu(); if (lines.length > 0) { boolean allWithHash = true; for (int i = 0; i < lines.length; i++) { if (lines[i].getHash() == null) { allWithHash = false; break; } } PopupUtils.addMenuItem( I18n.tr("Copy Magnet"), COPY_MAGNET_ACTION_LISTENER, menu, allWithHash); PopupUtils.addMenuItem(I18n.tr("Copy Hash"), COPY_HASH_ACTION_LISTENER, menu, allWithHash); menu.add(createSearchAgainMenu(lines[0])); } else { menu.add(new SkinMenuItem(new RepeatSearchAction())); } return (new SearchResultMenu(this)).addToMenu(menu, lines); }
@NotNull private JPopupMenu createMenu(final Node config) { JPopupMenu menu = new JPopupMenu(); final JCheckBoxMenuItem showRpmItem = new JCheckBoxMenuItem("Show RPM"); final JCheckBoxMenuItem showCommandsItem = new JCheckBoxMenuItem("Show Commands"); showRpmItem.setSelected(showRpmPanel); ActionListener showCheckboxListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { showRpmPanel = showRpmItem.isSelected(); showMessagesPanel = showCommandsItem.isSelected(); config.setProperty(SHOW_RPM, showRpmPanel); config.setProperty(SHOW_MESSAGES, showMessagesPanel); applyShowFlags(); // todo: this is not needed if we show/hide RPM panel. TODO: split into two different // listeners middleSplitPanel.setDividerLocation(0.5); } }; showRpmItem.addActionListener(showCheckboxListener); showCommandsItem.addActionListener(showCheckboxListener); menu.add(showRpmItem); showCommandsItem.setSelected(showMessagesPanel); menu.add(showCommandsItem); menu.add(new JPopupMenu.Separator()); menu.add(new JPopupMenu("Reset Config")); return menu; }
private void addEndingPopupMenu() { menuEnding = new JPopupMenu() { @Override public void show(Component c, int x, int y) { intEndingPopup = galotņuTabula.rowAtPoint(new Point(x, y)); super.show(c, x, y); } }; JMenuItem addEnding = new JMenuItem("Pievienot galotni"); addEnding.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (intEndingPopup >= 0 && intEndingPopup < galotņuTabula.getRowCount()) addEnding(); } }); JMenuItem deleteEnding = new JMenuItem("Dzēst galotni"); deleteEnding.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (intEndingPopup >= 0 && intEndingPopup < galotņuTabula.getRowCount()) deleteEnding(intEndingPopup); } }); menuEnding.add(addEnding); menuEnding.add(deleteEnding); galotņuTabula.setComponentPopupMenu(menuEnding); }
public ManagerPopupMenu() { jPopupMenu = new JPopupMenu(); Font font = new Font("Verdana", Font.PLAIN, 12); JMenuItem jFormProviderOrderItem = new JMenuItem("Отменить заказ"); jFormProviderOrderItem.setFont(font); jFormProviderOrderItem.addActionListener(e -> ClientWindow.this.cancelClientOrder()); jPopupMenu.add(jFormProviderOrderItem); jPopupMenu.addSeparator(); JMenuItem jPay25OrderItem = new JMenuItem("Оплатить часть заказа"); jPay25OrderItem.addActionListener( e -> ClientWindow.this.pay25Order( ((DefaultMutableTreeNode) e.getSource()).getUserObject().toString())); jPay25OrderItem.setFont(font); jPopupMenu.add(jPay25OrderItem); jPopupMenu.addSeparator(); JMenuItem jPayFullOrderItem = new JMenuItem("Оплатить весь заказ"); jPayFullOrderItem.addActionListener( e -> ClientWindow.this.payFullOrder( ((DefaultMutableTreeNode) e.getSource()).getUserObject().toString())); jPayFullOrderItem.setFont(font); jPopupMenu.add(jPayFullOrderItem); }
private void refreshMenu() { if (menuItems != null && menuItems.length > 0) { firstIndex = Math.max(topFixedCount, firstIndex); firstIndex = Math.min(menuItems.length - bottomFixedCount - scrollCount, firstIndex); upItem.setEnabled(firstIndex > topFixedCount); downItem.setEnabled(firstIndex + scrollCount < menuItems.length - bottomFixedCount); menu.removeAll(); for (int i = 0; i < topFixedCount; i++) { menu.add(menuItems[i]); } if (topFixedCount > 0) { menu.addSeparator(); } menu.add(upItem); for (int i = firstIndex; i < scrollCount + firstIndex; i++) { menu.add(menuItems[i]); } menu.add(downItem); if (bottomFixedCount > 0) { menu.addSeparator(); } for (int i = menuItems.length - bottomFixedCount; i < menuItems.length; i++) { menu.add(menuItems[i]); } JComponent parent = (JComponent) upItem.getParent(); parent.revalidate(); parent.repaint(); } }
public void createPopupMenu() { super.createPopupMenu(); JPopupMenu popupMenu = getPopupMenu(); if (popupMenu == null) { popupMenu = new JPopupMenu(); setPopupMenu(popupMenu); } else { popupMenu.addSeparator(); } propertiesItem = new JMenuItem("Properties ..."); propertiesItem.addActionListener(this); propertiesItem.setMnemonic('s'); popupMenu.add(propertiesItem); popupMenu.addSeparator(); ButtonGroup group = new ButtonGroup(); inItem = new JRadioButtonMenuItem("IN"); group.add(inItem); inItem.addActionListener(this); popupMenu.add(inItem); outItem = new JRadioButtonMenuItem("OUT"); group.add(outItem); outItem.addActionListener(this); popupMenu.add(outItem); inoutItem = new JRadioButtonMenuItem("INOUT"); group.add(inoutItem); inoutItem.addActionListener(this); popupMenu.add(inoutItem); }
private void setContextOptions(GameOptions gameType) { JPopupMenu contextOptions = new JPopupMenu(); JMenu addPieces = new JMenu(Resources.getString(Resources.ADD_PIECE)); String[] pieces = gameType.getPieceList(); for (int i = 0; i < pieces.length; i++) { JMenuItem newPieceName = new JMenuItem(pieces[i]); newPieceName.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println(((JMenuItem) e.getSource()).getText()); } }); addPieces.add(newPieceName); } contextOptions.add(addPieces); contextOptions.add(new JMenuItem(Resources.getString(Resources.DELETE_PIECE))); this.setComponentPopupMenu(contextOptions); }
@Override public JPopupMenu getComponentPopupMenu() { if (popupMenu == null) { popupMenu = new JPopupMenu(Messages.CHART_COLON); timeRangeMenu = new JMenu(Messages.PLOTTER_TIME_RANGE_MENU); timeRangeMenu.setMnemonic(Resources.getMnemonicInt(Messages.PLOTTER_TIME_RANGE_MENU)); popupMenu.add(timeRangeMenu); menuRBs = new JRadioButtonMenuItem[rangeNames.length]; ButtonGroup rbGroup = new ButtonGroup(); for (int i = 0; i < rangeNames.length; i++) { menuRBs[i] = new JRadioButtonMenuItem(rangeNames[i]); rbGroup.add(menuRBs[i]); menuRBs[i].addActionListener(this); if (viewRange == rangeValues[i]) { menuRBs[i].setSelected(true); } timeRangeMenu.add(menuRBs[i]); } popupMenu.addSeparator(); saveAsMI = new JMenuItem(Messages.PLOTTER_SAVE_AS_MENU_ITEM); saveAsMI.setMnemonic(Resources.getMnemonicInt(Messages.PLOTTER_SAVE_AS_MENU_ITEM)); saveAsMI.addActionListener(this); popupMenu.add(saveAsMI); } return popupMenu; }
protected JPopupMenu createPopUpMenu() { JPopupMenu menu = new JPopupMenu(); JMenu saveMenu = new JMenu("Save As.."); menu.add(saveMenu); JMenuItem item = new JMenuItem("PNG"); item.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { saveImage("PNG"); } }); saveMenu.add(item); item = new JMenuItem("JPEG"); item.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { saveImage("JPEG"); } }); saveMenu.add(item); JMenu[] menus = createMenus(); if (menus != null) { for (int i = 0; i < menus.length; i++) { menu.add(menus[i]); } } return menu; }
protected JPopupMenu createPopMenu() { JPopupMenu pop = new BasePopupMenu(); copy = new JMenuItem(PublicResource.getString("TextEditor.popmenu.copy"), IconResource.ICON_COPY); copy.addActionListener(new CopyAction()); paste = new JMenuItem( PublicResource.getString("TextEditor.popmenu.paste"), IconResource.ICON_PASTE); paste.addActionListener(new PasteAction()); cut = new JMenuItem(PublicResource.getString("TextEditor.popmenu.cut"), IconResource.ICON_CUT); cut.addActionListener(new CutAction()); selectAll = new JMenuItem( PublicResource.getString("TextEditor.popmenu.selectAll"), IconResource.getBlankIcon()); selectAll.addActionListener(new SelectAllAction()); pop.add(cut); pop.add(copy); pop.add(paste); pop.add(new JSeparator()); pop.add(selectAll); return pop; }
@Override protected JPopupMenu createPopup(Point p) { final List<Node> selectedElements = elementsDataTable.getElementsFromSelectedRows(); final Node clickedElement = elementsDataTable.getElementFromRow(table.rowAtPoint(p)); JPopupMenu contextMenu = new JPopupMenu(); // First add edges manipulators items: DataLaboratoryHelper dlh = DataLaboratoryHelper.getDefault(); Integer lastManipulatorType = null; for (NodesManipulator em : dlh.getNodesManipulators()) { em.setup(selectedElements.toArray(new Node[0]), clickedElement); if (lastManipulatorType == null) { lastManipulatorType = em.getType(); } if (lastManipulatorType != em.getType()) { contextMenu.addSeparator(); } lastManipulatorType = em.getType(); if (em.isAvailable()) { contextMenu.add( PopupMenuUtils.createMenuItemFromNodesManipulator( em, clickedElement, selectedElements.toArray(new Node[0]))); } } // Add AttributeValues manipulators submenu: Column column = elementsDataTable.getColumnAtIndex(table.columnAtPoint(p)); if (column != null) { contextMenu.add(PopupMenuUtils.createSubMenuFromRowColumn(clickedElement, column)); } return contextMenu; }
/** Creates a custom popup menu for the table header. */ private JPopupMenu createHeaderPopup() { // Create popup menu. JPopupMenu popupMenu = new JPopupMenu(); JMenuItem defaultItem = new JMenuItem(); defaultItem.setAction(defaultConfigAction); popupMenu.add(defaultItem); JMenu optionsMenu = new JMenu(I18n.tr("More Options")); popupMenu.add(optionsMenu); popupMenu.addSeparator(); JMenuItem autosortItem = new JCheckBoxMenuItem(); autosortItem.setAction(autosortAction); optionsMenu.add(autosortItem); JMenuItem tooltipsItem = new JCheckBoxMenuItem(); tooltipsItem.setAction(tooltipsAction); optionsMenu.add(tooltipsItem); // Get column headings in default order. int columnCount = tableFormat.getColumnCount(); for (int i = 0; i < columnCount; i++) { // Create checkbox menu item for each column heading. String headerName = tableFormat.getColumnName(i); JMenuItem item = new JCheckBoxMenuItem(headerName, true); item.addActionListener(toggleColumnAction); popupMenu.add(item); } return popupMenu; }
public void showContextMenu(final ContextMenuParams params) { final JPopupMenu popupMenu = new JPopupMenu(); if (!params.getLinkText().isEmpty()) { popupMenu.add( createMenuItem( "Open link in new window", new Runnable() { public void run() { String linkURL = params.getLinkURL(); System.out.println("linkURL = " + linkURL); } })); } final Browser browser = params.getBrowser(); popupMenu.add( createMenuItem( "Reload", new Runnable() { public void run() { browser.reload(); } })); final Point location = params.getLocation(); SwingUtilities.invokeLater( new Runnable() { public void run() { popupMenu.show(component, location.x, location.y); } }); }
private void addPopupMenu() { JPopupMenu menu = new JPopupMenu(); markItems = new JMenuItem[AlertsTableModel.status.length]; for (int i = 0; i < markItems.length; i++) { markItems[i] = menu.add("Mark as " + AlertsTableModel.status[i]); markItems[i].addActionListener(this); } menu.addSeparator(); moveToDetails = menu.add("View Related Flows for this Host"); menu.addSeparator(); deleteAlerts = menu.add("Delete"); deleteAlertsForHost = menu.add("Remove all Alerts for this Host"); deleteAlertTypeForHost = menu.add("Remove This Alert Type for this Host"); deleteAlerts.addActionListener(this); deleteAlertsForHost.addActionListener(this); deleteAlertTypeForHost.addActionListener(this); moveToDetails.addActionListener(this); table.setComponentPopupMenu(menu); }