Java Code Examples for javax.swing.JPopupMenu#show()
The following examples show how to use
javax.swing.JPopupMenu#show() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TextViewerComponent.java From visualvm with GNU General Public License v2.0 | 6 votes |
public void mouseClicked(MouseEvent e) { if (e.getModifiers() == InputEvent.BUTTON3_MASK) { if (isEnabled() && isFocusable() && showPopup) { JPopupMenu popup = getPopupMenu(); if (popup != null) { updatePopupMenu(); if (!hasFocus()) { requestFocus(); // required for Select All functionality } popup.show(this, e.getX(), e.getY()); } } } }
Example 2
Source File: FrmMeteoData.java From MeteoInfo with GNU Lesser General Public License v3.0 | 6 votes |
private void jList_DataFilesMouseClicked(java.awt.event.MouseEvent evt) { // TODO add your handling code here: //JOptionPane.showMessageDialog(null, this.jList_DataFiles.getSelectedValue().toString(), "", JOptionPane.INFORMATION_MESSAGE); if (evt.getButton() == MouseEvent.BUTTON1) { if (this.jList_DataFiles.getSelectedIndex() < 0 || this.jList_DataFiles.getSelectedIndex() == _selectedIndex) { return; } _meteoDataInfo = _dataInfoList.get(this.jList_DataFiles.getSelectedIndex()); updateParameters(); _selectedIndex = this.jList_DataFiles.getSelectedIndex(); } else if (evt.getButton() == MouseEvent.BUTTON3) { JPopupMenu mnuLayer = new JPopupMenu(); JMenuItem removeLayerMI = new JMenuItem("Remove Data File"); removeLayerMI.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { onRemoveDataClick(e); } }); mnuLayer.add(removeLayerMI); mnuLayer.show(this.jList_DataFiles, evt.getX(), evt.getY()); } }
Example 3
Source File: bug6544309.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private void setupUI() { dialog = new JDialog(); dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); dialog.setSize(200, 100); dialog.setLocationRelativeTo(null); dialog.setVisible(true); JPopupMenu popup = new JPopupMenu(); popup.add(new JMenuItem("one")); JMenuItem two = new JMenuItem("two"); two.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { passed = true; } }); popup.add(two); popup.add(new JMenuItem("three")); popup.show(dialog, 50, 50); }
Example 4
Source File: SettingsPage.java From xdm with GNU General Public License v2.0 | 6 votes |
private void showMoveQPopup(JButton btn) { int index = qList.getSelectedIndex(); if (index < 0) { return; } DownloadQueue q = queueModel.get(index); String qid = q.getQueueId(); if (qid == null) return; JPopupMenu popupMenu = new JPopupMenu(); for (int i = 0; i < QueueManager.getInstance().getQueueList().size(); i++) { DownloadQueue tq = QueueManager.getInstance().getQueueList().get(i); if (qid.equals(tq.getQueueId())) { continue; } JMenuItem item = new JMenuItem(tq.getName()); item.setName("Q_MOVE_TO:" + tq.getQueueId()); item.addActionListener(this); item.setForeground(Color.WHITE); item.setFont(FontResource.getNormalFont()); popupMenu.add(item); } popupMenu.setInvoker(btn); popupMenu.show(btn, 0, btn.getHeight()); }
Example 5
Source File: PurchaseInfoTab.java From pcgen with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void showPopup(MouseEvent e) { List<EquipmentFacade> targets = getMenuTargets(availableTable, e); if (targets.isEmpty()) { return; } JPopupMenu popupMenu = new JPopupMenu(); popupMenu.add(new BuyNumMenuItem(character, targets, 1)); JMenu buyMenu = new JMenu(LanguageBundle.getString("in_igBuyQuantity")); //$NON-NLS-1$ buyMenu.add(new BuyNumMenuItem(character, targets, 2)); buyMenu.add(new BuyNumMenuItem(character, targets, 5)); buyMenu.add(new BuyNumMenuItem(character, targets, 10)); buyMenu.add(new BuyNumMenuItem(character, targets, 15)); buyMenu.add(new BuyNumMenuItem(character, targets, 20)); buyMenu.add(new BuyNumMenuItem(character, targets, 50)); popupMenu.add(buyMenu); popupMenu.add(new BuyNumMenuItem(character, targets, 0)); popupMenu.addSeparator(); popupMenu.add(new AddCustomAction(character)); popupMenu.add(new DeleteCustomAction(character)); popupMenu.show(e.getComponent(), e.getX(), e.getY()); }
Example 6
Source File: ManagedBeanCustomizer.java From netbeans with Apache License 2.0 | 5 votes |
private void customizeTemplatesLabelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_customizeTemplatesLabelMouseClicked if (collection) { new OpenTemplateAction(this, NbBundle.getMessage(ManagedBeanCustomizer.class, "ManagedBeanCustomizer.tableTemplate"), JsfTemplateUtils.getTemplatePath(TemplateType.SNIPPETS, getTemplatesStyle(), TABLE_TEMPLATE)).actionPerformed(null); } else { JPopupMenu menu = new JPopupMenu(); String viewTemplatePath = JsfTemplateUtils.getTemplatePath(TemplateType.SNIPPETS, getTemplatesStyle(), VIEW_TEMPLATE); String editTemplatePath = JsfTemplateUtils.getTemplatePath(TemplateType.SNIPPETS, getTemplatesStyle(), EDIT_TEMPLATE); menu.add(new OpenTemplateAction(this, NbBundle.getMessage(ManagedBeanCustomizer.class, "ManagedBeanCustomizer.allTemplates"), viewTemplatePath, editTemplatePath)); menu.add(new OpenTemplateAction(this, NbBundle.getMessage(ManagedBeanCustomizer.class, "ManagedBeanCustomizer.viewTemplate"), viewTemplatePath)); menu.add(new OpenTemplateAction(this, NbBundle.getMessage(ManagedBeanCustomizer.class, "ManagedBeanCustomizer.editTemplate"), editTemplatePath)); menu.show(customizeTemplatesLabel, evt.getX(), evt.getY()); } }
Example 7
Source File: BuddyPanel.java From stendhal with GNU General Public License v2.0 | 5 votes |
@Override protected void showPopup(final MouseEvent e) { int index = BuddyPanel.this.locationToIndex(e.getPoint()); Buddy buddy = BuddyPanel.this.getModel().getElementAt(index); final JPopupMenu popup = new BuddyLabelPopMenu(buddy.getName(), buddy.isOnline()); popup.show(e.getComponent(), e.getX() - POPUP_OFFSET, e.getY() - POPUP_OFFSET); }
Example 8
Source File: DropdownButton.java From visualvm with GNU General Public License v2.0 | 5 votes |
public void displayPopup() { JPopupMenu menu = new JPopupMenu(); populatePopup(menu); if (menu.getComponentCount() > 0) { Dimension size = menu.getPreferredSize(); size.width = Math.max(size.width, getWidth()); menu.setPreferredSize(size); menu.show(this, 0, getHeight()); } }
Example 9
Source File: DBBrowserTree.java From nextreports-designer with Apache License 2.0 | 5 votes |
private void selectionDataSource(MouseEvent e) { if (e.getClickCount() == 2) { return; } AddDataSourceAction addDSAction = new AddDataSourceAction(); JPopupMenu popupMenu = new JPopupMenu(); JMenuItem menuItem = new JMenuItem(addDSAction); popupMenu.add(menuItem); popupMenu.show((Component) e.getSource(), e.getX(), e.getY()); }
Example 10
Source File: ActionMappings.java From netbeans with Apache License 2.0 | 5 votes |
public static void showAddPropertyPopupMenu(JButton btn, JTextComponent area, JTextField goalsField, @NullAllowed NbMavenProjectImpl project) { JPopupMenu menu = new JPopupMenu(); menu.add(new SkipTestsAction(area)); menu.add(new DebugMavenAction(area)); menu.add(new EnvVarAction(area)); menu.add(createJdkSubmenu(area)); menu.add(createGlobalVarSubmenu(area)); if (project != null) { menu.add(new PluginPropertyAction(area, goalsField, project)); } menu.add(createFileSelectionSubmenu(area)); menu.show(btn, btn.getSize().width, 0); }
Example 11
Source File: BoardPanel.java From Freerouting with GNU General Public License v3.0 | 5 votes |
private void mouse_clicked_action(java.awt.event.MouseEvent evt) { if (evt.getButton() == 1) { board_handling.left_button_clicked(evt.getPoint()); } else if (evt.getButton() == 3) { JPopupMenu curr_menu = board_handling.get_current_popup_menu(); if (curr_menu != null) { int curr_x = evt.getX(); int curr_y = evt.getY(); if (curr_menu == popup_menu_dynamic_route && board_frame.is_web_start) { int dx = curr_menu.getWidth(); if (dx <= 0) { // force the width to be calculated curr_menu.show(this, curr_x, curr_y); dx = curr_menu.getWidth(); } curr_x -= dx; } curr_menu.show(this, curr_x, curr_y); } right_button_click_location = evt.getPoint(); } }
Example 12
Source File: GuiMouseListener.java From WorldGrower with GNU General Public License v3.0 | 5 votes |
private void showPlayerCharacterMenu(int x, int y) { JPopupMenu menu = MenuFactory.createJPopupMenu(imageInfoReader); addPlayerCharacterInformationMenus(menu); JMenu organizationMenu = MenuFactory.createJMenu("Organization", ImageIds.BLACK_CROSS, imageInfoReader, soundIdReader); JMenu miscMenu = MenuFactory.createJMenu("Miscellaneous", ImageIds.INVESTIGATE, imageInfoReader, soundIdReader); addDisguiseMenu(miscMenu); addPropertiesMenu(menu, playerCharacter); createBuildActionsSubMenu(menu); addBuildProductionActions(menu); addPlantActions(menu); addIllusionActions(menu); addRestorationActions(menu); addTransmutationActions(menu); addEvocationActions(menu); addNecromancyActions(menu); addRestMenu(menu); menu.add(organizationMenu); addCreateOrganizationMenu(organizationMenu); addShowGovernanceMenu(organizationMenu); addShowCommunityActionMenu(organizationMenu); addChooseDeityMenu(miscMenu); addCreateHumanMeatMenu(miscMenu); addInvestigateMenu(miscMenu); addNewsPaperAction(miscMenu); menu.add(miscMenu); addAssignActionsToLeftMouse(menu); menu.show(container, x, y); }
Example 13
Source File: DropdownButton.java From netbeans with Apache License 2.0 | 5 votes |
public void displayPopup() { JPopupMenu menu = new JPopupMenu(); populatePopup(menu); if (menu.getComponentCount() > 0) { Dimension size = menu.getPreferredSize(); size.width = Math.max(size.width, getWidth()); menu.setPreferredSize(size); menu.show(this, 0, getHeight()); } }
Example 14
Source File: FileSystemExtension.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** @param e */ private void treeSelected(MouseEvent e) { if (SwingUtilities.isRightMouseButton(e)) { int row = tree.getClosestRowForLocation(e.getX(), e.getY()); tree.setSelectionRow(row); Object selectedItem = tree.getLastSelectedPathComponent(); Thread t1 = new Thread( new Runnable() { public void run() { JPopupMenu popupMenu = new JPopupMenu(); List<FileSystemInterface> extensionList = FileSystemExtensionFactory.getFileExtensionList( toolMgr); for (FileSystemInterface extension : extensionList) { extension.rightMouseButton(popupMenu, selectedItem, e); } if ((popupMenu.getComponentCount() > 0) && (e != null)) { popupMenu.show(e.getComponent(), e.getX(), e.getY()); } } }); t1.start(); } }
Example 15
Source File: TreeMouseListener.java From nmonvisualizer with Apache License 2.0 | 5 votes |
@Override protected void onRootPath() { if (gui.getDataSetCount() > 0) { JPopupMenu menu = new JPopupMenu(); JMenuItem item = new JMenuItem("Save Summary Charts..."); item.addActionListener(saveChartsAction); menu.add(item); menu.show(event.getComponent(), event.getX(), event.getY()); } }
Example 16
Source File: VisualGraphPopupMousePlugin.java From ghidra with Apache License 2.0 | 5 votes |
@Override protected void handlePopup(MouseEvent e) { VisualizationViewer<V, E> viewer = getViewer(e); // GraphElementAccessor<V, E> pickSupport = viewer.getPickSupport(); // PickedState<V> pickedVertexState = viewer.getPickedVertexState(); // PickedState<E> pickedEdgeState = viewer.getPickedEdgeState(); // JPopupMenu popup = new JPopupMenu(); popup.show(viewer, e.getX(), e.getY()); }
Example 17
Source File: SymbolsEditor.java From libreveris with GNU Lesser General Public License v3.0 | 5 votes |
private void showPagePopup (Point pt) { pageMenu.updateMenu(new Point(pt.x, pt.y)); JPopupMenu popup = pageMenu.getPopup(); popup.show( this, getZoom().scaled(pt.x) + 20, getZoom().scaled(pt.y) + 30); }
Example 18
Source File: DropDownButton.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
@Override public void loggedActionPerformed(ActionEvent ae) { JPopupMenu popup = getPopupMenu(); popup.addPopupMenuListener(popupMenuListener); popup.show(mainButton, isRightAlign() ? -popup.getPreferredSize().width + mainButton.getWidth() + arrowButton.getWidth() : 0, mainButton.getHeight()); }
Example 19
Source File: MiniEdit.java From netbeans with Apache License 2.0 | 4 votes |
public void mousePressed(java.awt.event.MouseEvent e) { if (e.isPopupTrigger()) { JPopupMenu menu = engine.createPopupMenu(); menu.show((Component) e.getSource(), e.getX(), e.getY()); } }
Example 20
Source File: InstructionList.java From Cafebabe with GNU General Public License v3.0 | 4 votes |
protected void showPopupMenu() { int selections[] = this.getSelectedIndices(); if (selections.length == 1) { InstructionNode selection = this.getModel().getElementAt(selections[0]); JPopupMenu menu = new JPopupMenu(); JMenuItem add = new JMenuItem(Translations.get("Insert instruction")); add.addActionListener(l -> { mn.instructions.insert(selection.ain, new InsnNode(Opcodes.NOP)); this.refresh(mn); this.setSelectedIndex(selections[0] + 1); }); menu.add(add); JMenuItem addLabel = new JMenuItem(Translations.get("Insert label")); addLabel.addActionListener(l -> { mn.instructions.insert(selection.ain, new LabelNode()); this.refresh(mn); this.setSelectedIndex(selections[0] + 1); }); menu.add(addLabel); JMenuItem remove = new JMenuItem(Translations.get("Remove")); remove.addActionListener(l -> { mn.instructions.remove(selection.ain); this.refresh(mn); }); menu.add(remove); JMenuItem dupe = new JMenuItem(Translations.get("Clone")); dupe.addActionListener(l -> { mn.instructions.insert(selection.ain, Code.cloneNode(selection.ain)); this.refresh(mn); this.setSelectedIndex(selections[0]); }); menu.add(dupe); menu.add(new JSeparator()); AbstractInsnNode prev = selection.ain.getPrevious(); JMenuItem up = new JMenuItem(Translations.get("Move up")); up.addActionListener(l -> { mn.instructions.remove(prev); mn.instructions.insert(selection.ain, prev); this.refresh(mn); this.setSelectedIndex(selections[0] - 1); }); up.setEnabled(prev != null); menu.add(up); AbstractInsnNode next = selection.ain.getNext(); JMenuItem down = new JMenuItem(Translations.get("Move down")); down.addActionListener(l -> { mn.instructions.remove(next); mn.instructions.insertBefore(selection.ain, next); this.refresh(mn); this.setSelectedIndex(selections[0] + 1); }); menu.add(down); down.setEnabled(next != null); menu.add(new JSeparator()); JMenuItem copy = new JMenuItem(Translations.get("Copy")); copy.addActionListener(l -> { // TODO maybe copy to clipboard to allow transfer between different applications copiedItem = selection; }); menu.add(copy); JMenuItem paste = new JMenuItem(Translations.get("Paste")); paste.addActionListener(l -> { mn.instructions.insert(selection.ain, Code.cloneNode(copiedItem.ain)); this.refresh(mn); this.setSelectedIndex(selections[0]); }); paste.setEnabled(copiedItem != null); menu.add(paste); menu.add(new JSeparator()); JMenuItem copyText = new JMenuItem(Translations.get("Copy text")); copyText.addActionListener(l -> { StringSelection stringSelection = new StringSelection(selection.toString().replaceAll("<[^>]*>", "")); Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringSelection, stringSelection); }); menu.add(copyText); menu.show(Cafebabe.gui.editorFrame, (int) Cafebabe.gui.editorFrame.getMousePosition().getX(), (int) Cafebabe.gui.editorFrame.getMousePosition().getY()); } else if (selections.length > 1) { return; } }