List of usage examples for javax.swing JPopupMenu JPopupMenu
public JPopupMenu()
JPopupMenu
without an "invoker". From source file:brainflow.app.toplevel.BrainFlow.java
private JPopupMenu createPopup(java.util.List<Action> actionList) { JPopupMenu menu = new JPopupMenu(); for (Action action : actionList) { menu.add(action);/*from w ww.j a v a2 s. c o m*/ } return menu; }
From source file:com.mirth.connect.client.ui.components.rsta.MirthRSyntaxTextArea.java
@Override protected JPopupMenu createPopupMenu() { JPopupMenu menu = new JPopupMenu(); menu.add(undoMenuItem);/*from w w w .j a v a2s. c om*/ menu.add(redoMenuItem); menu.addSeparator(); menu.add(cutMenuItem); menu.add(copyMenuItem); menu.add(pasteMenuItem); menu.add(deleteMenuItem); menu.addSeparator(); menu.add(selectAllMenuItem); menu.add(findReplaceMenuItem); menu.add(findNextMenuItem); menu.add(clearMarkedOccurrencesMenuItem); menu.addSeparator(); foldingMenu.add(collapseFoldMenuItem); foldingMenu.add(expandFoldMenuItem); foldingMenu.add(collapseAllFoldsMenuItem); foldingMenu.add(collapseAllCommentFoldsMenuItem); foldingMenu.add(expandAllFoldsMenuItem); menu.add(foldingMenu); menu.addSeparator(); displayMenu.add(showTabLinesMenuItem); displayMenu.add(showWhitespaceMenuItem); displayMenu.add(showLineEndingsMenuItem); displayMenu.add(wrapLinesMenuItem); menu.add(displayMenu); menu.addSeparator(); macroMenu.add(beginMacroMenuItem); macroMenu.add(endMacroMenuItem); macroMenu.add(playbackMacroMenuItem); menu.add(macroMenu); menu.addSeparator(); menu.add(viewUserAPIMenuItem); return menu; }
From source file:edu.ku.brc.specify.tasks.QueryTask.java
@Override public JPopupMenu getPopupMenu() { JPopupMenu popupMenu = new JPopupMenu(); JMenuItem mi = new JMenuItem(UIRegistry.getResourceString("QY_CONFIGURE_CREATORS")); popupMenu.add(mi);//from w ww . j av a 2s . c o m mi.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { configureCreatorQueries(); } }); mi = new JMenuItem(UIRegistry.getResourceString("QY_CONFIGURE_QUERIES")); popupMenu.add(mi); mi.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { configureFavoriteQueries(); } }); mi = new JMenuItem(UIRegistry.getResourceString("QY_IMPORT_QUERIES")); popupMenu.add(mi); mi.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { importQueries(); } }); mi = new JMenuItem(UIRegistry.getResourceString("QY_EXPORT_QUERIES")); popupMenu.add(mi); mi.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { exportQueries(); } }); return popupMenu; }
From source file:gdt.jgui.entity.JEntityDigestDisplay.java
private JPopupMenu getCollapsePopupMenu() { //System.out.println("JEntityDigestDisplay:getCollapsePopupMenu:selection="+Locator.remove(selection$, Locator.LOCATOR_ICON)); JPopupMenu popup = new JPopupMenu(); JMenuItem collapseItem = new JMenuItem("Collapse"); popup.add(collapseItem);//from w w w. ja v a 2 s .c om collapseItem.setHorizontalTextPosition(JMenuItem.RIGHT); collapseItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); int cnt = node.getChildCount(); Stack<DefaultMutableTreeNode> s = new Stack<DefaultMutableTreeNode>(); if (cnt > 0) { DefaultMutableTreeNode child; for (int i = 0; i < cnt; i++) { child = (DefaultMutableTreeNode) node.getChildAt(i); s.push(child); } } while (!s.isEmpty()) tree.collapsePath(new TreePath(s.pop().getPath())); } catch (Exception ee) { } } }); return popup; }
From source file:net.sf.nmedit.nomad.core.Nomad.java
private JToolBar createQuickActionToolbar() { JToolBar toolbar = new JToolBar(); toolbar.setBorderPainted(false);//from www . j av a 2 s. c o m toolbar.setFloatable(false); toolbar.add(Factory.createToolBarButton(menuLayout.getEntry(MENU_FILE_OPEN))); toolbar.addSeparator(); toolbar.add(Factory.createToolBarButton(menuLayout.getEntry(MENU_FILE_SAVE))); toolbar.addSeparator(); JPopupMenu pop = new JPopupMenu(); Iterator<FileService> iter = ServiceRegistry.getServices(FileService.class); JRadioButtonMenuItem rfirst = null; SelectedAction sa = new SelectedAction(); sa.putValue(AbstractAction.SMALL_ICON, getImage("/icons/tango/16x16/actions/document-new.png")); while (iter.hasNext()) { FileService fs = iter.next(); if (fs.isNewFileOperationSupported()) { JRadioButtonMenuItem rb = new JRadioButtonMenuItem( new AHAction(fs.getName(), fs.getIcon(), fs, "newFile")); sa.add(rb); pop.add(rb); if (rfirst == null) rfirst = rb; } } JButton btn = Factory.createToolBarButton(sa); toolbar.add(btn); new JDropDownButtonControl(btn, pop); return toolbar; }
From source file:edu.ku.brc.specify.tasks.SystemSetupTask.java
/** * Adds the Context PopupMenu for the RecordSet. * @param roc the RolloverCommand btn to add the pop to *///from ww w.j a v a2 s.c o m public void addPopMenu(final RolloverCommand roc, final PickList pickList) { if (roc.getLabelText() != null) { final JPopupMenu popupMenu = new JPopupMenu(); JMenuItem delMenuItem = new JMenuItem(getResourceString("Delete")); if (!pickList.getIsSystem()) { delMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { CommandDispatcher.dispatch(new CommandAction(SYSTEMSETUPTASK, DELETE_CMD_ACT, roc)); } }); } else { delMenuItem.setEnabled(false); } popupMenu.add(delMenuItem); JMenuItem viewMenuItem = new JMenuItem(getResourceString("EDIT")); viewMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { startEditor(edu.ku.brc.specify.datamodel.PickList.class, "name", roc.getName(), roc.getName(), PICKLIST); } }); popupMenu.add(viewMenuItem); MouseListener mouseListener = new MouseAdapter() { private boolean showIfPopupTrigger(MouseEvent mouseEvent) { if (roc.isEnabled() && mouseEvent.isPopupTrigger() && popupMenu.getComponentCount() > 0) { popupMenu.show(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY()); return true; } return false; } @Override public void mousePressed(MouseEvent mouseEvent) { if (roc.isEnabled()) { showIfPopupTrigger(mouseEvent); } } @Override public void mouseReleased(MouseEvent mouseEvent) { if (roc.isEnabled()) { showIfPopupTrigger(mouseEvent); } } }; roc.addMouseListener(mouseListener); } }
From source file:org.forester.archaeopteryx.ControlPanel.java
private void buildJSlider(int width, int min, int max) { _color_branches_edpl_slider = new JSlider(min, max); Dimension d = _color_branches_edpl_slider.getSize(); d.width = width;/*from w w w . j a va 2s .co m*/ d.height = 100; _color_branches_edpl_slider.setPreferredSize(d); // _color_branches_edpl_slider.setLayout(null); // slider popup with cutoff value _slider_popup = new JPopupMenu(); JLabel text = new JLabel(); text.setText(String.valueOf(_edpl_current_cutoff)); _slider_popup.add(text); if (!_configuration.isUseNativeUI()) { _color_branches_edpl_slider.setBackground(ControlPanel.jcb_background_color); _color_branches_edpl_slider.setForeground(ControlPanel.jcb_text_color); } _color_branches_edpl_slider.setToolTipText("Set cutoff for EDPL (0.5-1.0)"); _color_branches_edpl_slider.setMinorTickSpacing(10); _color_branches_edpl_slider.setMajorTickSpacing(50); _color_branches_edpl_slider.setPaintTicks(true); _color_branches_edpl_slider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { // get Treepanel function final TreePanel tp = getMainPanel().getCurrentTreePanel(); if (tp == null) { return; } Phylogeny phy = tp.getPhylogeny(); _edpl_next_cutoff = ((double) ((JSlider) (e.getSource())).getValue() / 100.0); tp.edplSliderMovement(_edpl_next_cutoff, _edpl_current_cutoff); _edpl_current_cutoff = _edpl_next_cutoff; // System.out.println("Neuer Wert: "+ // ((JSlider)(e.getSource())).getValue()); } }); _color_branches_edpl_slider.addMouseMotionListener(new MouseMotionListener() { @Override public void mouseMoved(MouseEvent e) { if (_color_branches_edpl_slider.isEnabled()) { _slider_popup.setVisible(false); } } @Override public void mouseDragged(MouseEvent e) { if (_color_branches_edpl_slider.isEnabled()) { // Point p = getMainPanel().getMainFrame().getLocation(); Point p = _color_branches_edpl_slider.getLocationOnScreen(); JLabel text = (JLabel) _slider_popup.getComponent(0); text.setText(String.valueOf(_edpl_current_cutoff)); int x = (int) p.getX() + 18; int y = (int) p.getY() - 25; _slider_popup.setLocation(x, y); _slider_popup.setVisible(true); } } }); }
From source file:it.unibas.spicygui.vista.JLayeredPaneCorrespondences.java
private void creaPopUpMappingTaskTreeTarget() { this.popUpMenuTarget = new JPopupMenu(); this.popUpMenuTarget.add(new ActionViewAllVirtualNode(targetSchemaTree)); this.targetSchemaTree.addMouseListener(new PopUpListenerMappingTaskTreeTarget()); }
From source file:it.unibas.spicygui.vista.JLayeredPaneCorrespondences.java
private void creaPopUpMappingTaskTreeTargetMakeConnection() { this.popUpMenuTargetMakeConnection = new JPopupMenu(); this.popUpMenuTargetMakeConnection .add(new ActionMakeSource(targetSchemaTree, scenario.getMappingTask(), false)); this.popUpMenuTargetMakeConnection .add(new ActionMakeTarget(targetSchemaTree, this, scenario.getMappingTask(), false)); this.targetSchemaTree.addMouseListener(new PopUpListenerMappingTaskTreeTarget()); }
From source file:ca.phon.ipamap.IpaMap.java
private void init() { setLayout(new BorderLayout()); // favorites/*from ww w . j av a 2 s. c o m*/ IpaGrids favData = getFavData(); final Grid fg = favData.getGrid().get(0); favPanel = getGridPanel(fg); favPanel.setCollapsed(getSavedSectionToggle(fg.getName())); favToggleButton = getToggleButton(fg, favPanel); favToggleButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setSavedSectionToggle(fg.getName(), !getSavedSectionToggle(fg.getName())); } }); JPanel favSection = new JPanel(new VerticalLayout(0)); favSection.add(favToggleButton); favSection.add(favPanel); favContainer = favSection; // search Grid emptyGrid = (new ObjectFactory()).createGrid(); emptyGrid.setName("Search Results (0)"); emptyGrid.setRows(0); emptyGrid.setCols(0); searchPanel = getGridPanel(emptyGrid); searchToggleButton = getToggleButton(emptyGrid, searchPanel); final JButton searchButton = new JButton("Search"); searchButton.putClientProperty("JComponent.sizeVariant", "small"); searchButton.addActionListener(this::showSearchFrame); JPanel searchSection = new JPanel(new VerticalLayout(0)); searchSection.add(searchButton); searchSection.add(searchToggleButton); searchContainer = searchSection; // static content final JPanel centerPanel = new JPanel(new VerticalLayout(0)); IpaGrids grids = getGridData(); for (final Grid grid : grids.getGrid()) { final JXCollapsiblePane cp = getGridPanel(grid); cp.setCollapsed(getSavedSectionToggle(grid.getName())); JXButton toggleBtn = getToggleButton(grid, cp); toggleBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setSavedSectionToggle(grid.getName(), !getSavedSectionToggle(grid.getName())); } }); toggleButtons.add(toggleBtn); centerPanel.add(toggleBtn); centerPanel.add(cp); gridPanels.add(cp); } scrollPane = new JScrollPane(centerPanel); scrollPane.setAutoscrolls(true); scrollPane.setWheelScrollingEnabled(true); // scrollPane.setViewportView(centerPanel); add(scrollPane, BorderLayout.CENTER); // JPanel btmPanel = new JPanel(new BorderLayout()); // scalePanel.add(smallLbl, BorderLayout.WEST); // scalePanel.add(scaleSlider, BorderLayout.CENTER); // scalePanel.add(largeLbl, BorderLayout.EAST); final JButton scrollBtn = new JButton("-"); scrollBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { // popupMenu.show(scrollBtn, 0, scrollBtn.getHeight()); JPopupMenu ctxMenu = new JPopupMenu(); setupContextMenu(ctxMenu, scrollBtn); ctxMenu.show(scrollBtn, 0, scrollBtn.getHeight()); } }); // Font infoFont = new Font("Courier New", Font.PLAIN, 12); infoLabel = new JLabel(); infoLabel.setFont(infoLabel.getFont().deriveFont(Font.ITALIC)); infoLabel.setText("[]"); infoLabel.setOpaque(false); statusBar = new JXStatusBar(); statusBar.setLayout(new BorderLayout()); statusBar.add(infoLabel, BorderLayout.CENTER); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); scrollPane.setCorner(ScrollPaneConstants.LOWER_RIGHT_CORNER, scrollBtn); add(statusBar, BorderLayout.SOUTH); JPanel topPanel = new JPanel(new VerticalLayout(0)); topPanel.add(searchSection); topPanel.add(favSection); add(topPanel, BorderLayout.NORTH); }