List of usage examples for javax.swing JPopupMenu JPopupMenu
public JPopupMenu()
JPopupMenu
without an "invoker". From source file:gdt.jgui.entity.JEntityStructurePanel.java
/** * The default constructor.// w ww .j ava2 s . c o m */ public JEntityStructurePanel() { setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); scrollPane = new JScrollPane(); add(scrollPane); popup = new JPopupMenu(); popup.addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { popup.removeAll(); JMenuItem facetsItem = new JMenuItem("Facets"); popup.add(facetsItem); facetsItem.setHorizontalTextPosition(JMenuItem.RIGHT); facetsItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // System.out.println("EntityStructurePanel:renderer:component locator$="+nodeLocator$); JEntityFacetPanel efp = new JEntityFacetPanel(); String efpLocator$ = efp.getLocator(); Properties locator = Locator.toProperties(selection$); String entihome$ = locator.getProperty(Entigrator.ENTIHOME); String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY); efpLocator$ = Locator.append(efpLocator$, Entigrator.ENTIHOME, entihome$); efpLocator$ = Locator.append(efpLocator$, EntityHandler.ENTITY_KEY, entityKey$); JConsoleHandler.execute(console, efpLocator$); } }); JMenuItem copyItem = new JMenuItem("Copy"); popup.add(copyItem); copyItem.setHorizontalTextPosition(JMenuItem.RIGHT); copyItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { console.clipboard.clear(); String locator$ = (String) node.getUserObject(); if (locator$ != null) console.clipboard.putString(locator$); } }); if (!isFirst) { popup.addSeparator(); JMenuItem excludeItem = new JMenuItem("Exclude"); popup.add(excludeItem); excludeItem.setHorizontalTextPosition(JMenuItem.RIGHT); excludeItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int response = JOptionPane.showConfirmDialog(console.getContentPanel(), "Exclude ?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.YES_OPTION) { try { Properties locator = Locator.toProperties(selection$); String entihome$ = locator.getProperty(Entigrator.ENTIHOME); String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY); Entigrator entigrator = console.getEntigrator(entihome$); Sack component = entigrator.getEntityAtKey(entityKey$); String[] sa = entigrator.ent_listContainers(component); if (sa != null) { Sack container; for (String aSa : sa) { container = entigrator.getEntityAtKey(aSa); if (container != null) entigrator.col_breakRelation(container, component); } } JConsoleHandler.execute(console, JEntityStructurePanel.this.locator$); } catch (Exception ee) { Logger.getLogger(JEntityStructurePanel.class.getName()).info(ee.toString()); } } } }); JMenuItem deleteItem = new JMenuItem("Delete"); popup.add(deleteItem); deleteItem.setHorizontalTextPosition(JMenuItem.RIGHT); deleteItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int response = JOptionPane.showConfirmDialog(console.getContentPanel(), "Delete ?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.YES_OPTION) { try { Properties locator = Locator.toProperties(selection$); String entihome$ = locator.getProperty(Entigrator.ENTIHOME); String entityKey$ = locator.getProperty(EntityHandler.ENTITY_KEY); Entigrator entigrator = console.getEntigrator(entihome$); Sack component = entigrator.getEntityAtKey(entityKey$); entigrator.deleteEntity(component); JConsoleHandler.execute(console, JEntityStructurePanel.this.locator$); } catch (Exception ee) { Logger.getLogger(JEntityStructurePanel.class.getName()).info(ee.toString()); } } } }); } if (hasToInclude()) { popup.addSeparator(); JMenuItem includeItem = new JMenuItem("Include"); popup.add(includeItem); includeItem.setHorizontalTextPosition(JMenuItem.RIGHT); includeItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { include(); JConsoleHandler.execute(console, JEntityStructurePanel.this.locator$); } }); } } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { } @Override public void popupMenuCanceled(PopupMenuEvent e) { // TODO Auto-generated method stub } }); }
From source file:org.pgptool.gui.ui.keyslist.KeysTableView.java
@Override protected void internalInitComponents() { panelRoot = new JPanel(new BorderLayout()); initFormComponents();/*from www. j a v a 2 s . c o m*/ ctxMenu = new JPopupMenu(); }
From source file:net.landora.video.ui.UIAddon.java
public JPopupMenu createPopupMenu(Collection<?> context) { MultiValueMap valuesByClass = UIUtils.createCompleteContextByClass(context); List<UIAction<?>> actionsToUse = new ArrayList(); for (UIAction<?> action : actions) { Class<?> clazz = action.getRequiredClass(); Collection<?> col = valuesByClass.getCollection(clazz); if (col == null || col.isEmpty()) { continue; }/*from w w w.j a va2 s.c om*/ if (action.isMultipuleObjectSupport() || col.size() == 1) { actionsToUse.add(action); } } if (actionsToUse.isEmpty()) { return null; } JPopupMenu menu = new JPopupMenu(); for (UIAction<?> action : actionsToUse) { JMenuItem item = new JMenuItem(action.getName()); item.addActionListener( new UIActionAction(action, valuesByClass.getCollection(action.getRequiredClass()))); menu.add(item); } return menu; }
From source file:it.unibas.spicygui.vista.InstanceTreeTabbedPane.java
private void creaPopUp() { this.popUpMenu = new JPopupMenu(); this.popUpMenu.add(new ActionViewSkolemFunctor(this.albero)); this.popUpMenu.add(new ActionViewAllSkolemFunctors(this.albero)); this.popUpMenu.add(new ActionViewProvenance(this.albero)); this.popUpMenu.add(new ActionViewAllProvenance(this.albero)); this.popUpMenu.add(new ActionViewOID(this.albero)); // JCheckBoxMenuItem item = new JCheckBoxMenuItem(new ActionSetOIDType(this.albero)); // this.popUpMenu.add(item); this.albero.addMouseListener(new PopUpListener()); }
From source file:org.cds06.speleograph.graph.SeriesMenu.java
private JPopupMenu createPopupMenuForSeries(final Series series) { if (series == null) return new JPopupMenu(); final JPopupMenu menu = new JPopupMenu(series.getName()); menu.removeAll();//from www . ja v a2 s . c o m menu.add(new AbstractAction() { { putValue(NAME, "Renommer la srie"); } @Override public void actionPerformed(ActionEvent e) { menu.setVisible(false); String newName = ""; while (newName == null || newName.equals("")) { newName = (String) JOptionPane.showInputDialog(application, "Entrez un nouveau nom pour la srie", null, JOptionPane.QUESTION_MESSAGE, null, null, series.getName()); } series.setName(newName); } }); if (series.hasOwnAxis()) { menu.add(new AbstractAction() { { putValue(NAME, "Supprimer l'axe spcifique"); } @Override public void actionPerformed(ActionEvent e) { if (JOptionPane.showConfirmDialog(application, "tes vous sr de vouloir supprimer cet axe ?", "Confirmation", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) { series.setAxis(null); } } }); } else { menu.add(new JMenuItem(new AbstractAction() { { putValue(NAME, "Crer un axe spcifique pour la srie"); } @Override public void actionPerformed(ActionEvent e) { String name = JOptionPane.showInputDialog(application, "Quel titre pour cet axe ?", series.getAxis().getLabel()); if (name == null || "".equals(name)) return; // User has canceled series.setAxis(new NumberAxis(name)); } })); } menu.add(new SetTypeMenu(series)); if (series.isWater()) { menu.addSeparator(); menu.add(new SumOnPeriodAction(series)); menu.add(new CreateCumulAction(series)); } if (series.isWaterCumul()) { menu.addSeparator(); menu.add(new SamplingAction(series)); } if (series.isPressure()) { menu.addSeparator(); menu.add(new CorrelateAction(series)); menu.add(new WaterHeightAction(series)); } menu.addSeparator(); menu.add(new AbstractAction() { { String name; if (series.canUndo()) name = "Annuler " + series.getItemsName(); else name = series.getLastUndoName(); putValue(NAME, name); if (series.canUndo()) setEnabled(true); else { setEnabled(false); } } @Override public void actionPerformed(ActionEvent e) { series.undo(); } }); menu.add(new AbstractAction() { { String name; if (series.canRedo()) { name = "Refaire " + series.getNextRedoName(); setEnabled(true); } else { name = series.getNextRedoName(); setEnabled(false); } putValue(NAME, name); } @Override public void actionPerformed(ActionEvent e) { series.redo(); } }); menu.add(new AbstractAction() { { putValue(NAME, I18nSupport.translate("menus.serie.resetSerie")); if (series.canUndo()) setEnabled(true); else setEnabled(false); } @Override public void actionPerformed(ActionEvent e) { series.reset(); } }); menu.add(new LimitDateRangeAction(series)); menu.add(new HourSettingAction(series)); menu.addSeparator(); { JMenuItem deleteItem = new JMenuItem("Supprimer la srie"); deleteItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (JOptionPane.showConfirmDialog(application, "tes-vous sur de vouloir supprimer cette srie ?\n" + "Cette action est dfinitive.", "Confirmation", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) { series.delete(); } } }); menu.add(deleteItem); } menu.addSeparator(); { final JMenuItem up = new JMenuItem("Remonter dans la liste"), down = new JMenuItem("Descendre dans la liste"); ActionListener listener = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (e.getSource().equals(up)) { series.upSeriesInList(); } else { series.downSeriesInList(); } } }; up.addActionListener(listener); down.addActionListener(listener); if (series.isFirst()) { menu.add(down); } else if (series.isLast()) { menu.add(up); } else { menu.add(up); menu.add(down); } } menu.addSeparator(); { menu.add(new SeriesInfoAction(series)); } { JMenuItem colorItem = new JMenuItem("Couleur de la srie"); colorItem.addActionListener(new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { series.setColor(JColorChooser.showDialog(application, I18nSupport.translate("actions.selectColorForSeries"), series.getColor())); } }); menu.add(colorItem); } { JMenu plotRenderer = new JMenu("Affichage de la srie"); final ButtonGroup modes = new ButtonGroup(); java.util.List<DrawStyle> availableStyles; if (series.isMinMax()) { availableStyles = DrawStyles.getDrawableStylesForHighLow(); } else { availableStyles = DrawStyles.getDrawableStyles(); } for (final DrawStyle s : availableStyles) { final JRadioButtonMenuItem item = new JRadioButtonMenuItem(DrawStyles.getHumanCheckboxText(s)); item.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { if (item.isSelected()) series.setStyle(s); } }); modes.add(item); if (s.equals(series.getStyle())) { modes.setSelected(item.getModel(), true); } plotRenderer.add(item); } menu.add(plotRenderer); } menu.addSeparator(); menu.add(new AbstractAction() { { putValue(Action.NAME, "Fermer le fichier"); } @Override public void actionPerformed(ActionEvent e) { if (JOptionPane.showConfirmDialog(application, "tes-vous sur de vouloir fermer toutes les sries du fichier ?", "Confirmation", JOptionPane.OK_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.OK_OPTION) { final File f = series.getOrigin(); for (final Series s : Series.getInstances().toArray(new Series[Series.getInstances().size()])) { if (s.getOrigin().equals(f)) s.delete(); } } } }); return menu; }
From source file:net.sf.mzmine.desktop.impl.projecttree.ProjectTreeMouseHandler.java
/** * Constructor/*ww w . j a va2 s . com*/ */ public ProjectTreeMouseHandler(ProjectTree tree) { this.tree = tree; dataFilePopupMenu = new JPopupMenu(); GUIUtils.addMenuItem(dataFilePopupMenu, "Show TIC", this, "SHOW_TIC"); GUIUtils.addMenuItem(dataFilePopupMenu, "Show mass spectrum", this, "SHOW_SPECTRUM"); GUIUtils.addMenuItem(dataFilePopupMenu, "Show 2D visualizer", this, "SHOW_2D"); GUIUtils.addMenuItem(dataFilePopupMenu, "Show 3D visualizer", this, "SHOW_3D"); GUIUtils.addMenuItem(dataFilePopupMenu, "Show MS/MS visualizer", this, "SHOW_IDA"); GUIUtils.addMenuItem(dataFilePopupMenu, "Sort alphabetically", this, "SORT_FILES"); GUIUtils.addMenuItem(dataFilePopupMenu, "Remove file extension", this, "REMOVE_EXTENSION"); GUIUtils.addMenuItem(dataFilePopupMenu, "Remove", this, "REMOVE_FILE"); scanPopupMenu = new JPopupMenu(); GUIUtils.addMenuItem(scanPopupMenu, "Show scan", this, "SHOW_SCAN"); massListPopupMenu = new JPopupMenu(); GUIUtils.addMenuItem(massListPopupMenu, "Show mass list", this, "SHOW_MASSLIST"); GUIUtils.addMenuItem(massListPopupMenu, "Remove mass list", this, "REMOVE_MASSLIST"); GUIUtils.addMenuItem(massListPopupMenu, "Remove all mass lists with this name", this, "REMOVE_ALL_MASSLISTS"); peakListPopupMenu = new JPopupMenu(); GUIUtils.addMenuItem(peakListPopupMenu, "Show peak list table", this, "SHOW_PEAKLIST_TABLES"); GUIUtils.addMenuItem(peakListPopupMenu, "Show peak list info", this, "SHOW_PEAKLIST_INFO"); GUIUtils.addMenuItem(peakListPopupMenu, "Show scatter plot", this, "SHOW_SCATTER_PLOT"); GUIUtils.addMenuItem(peakListPopupMenu, "Sort alphabetically", this, "SORT_PEAKLISTS"); GUIUtils.addMenuItem(peakListPopupMenu, "Remove", this, "REMOVE_PEAKLIST"); peakListRowPopupMenu = new JPopupMenu(); GUIUtils.addMenuItem(peakListRowPopupMenu, "Show peak summary", this, "SHOW_PEAK_SUMMARY"); }
From source file:de.fhbingen.wbs.wpOverview.tabs.APCalendarPanel.java
/** * Initialize the work package calendar panel inclusive the listeners. *//*from w ww . j a v a2 s .co m*/ private void init() { List<Workpackage> userWp = new ArrayList<Workpackage>(WpManager.getUserWp(WPOverview.getUser())); Collections.sort(userWp, new APLevelComparator()); dataset = createDataset(userWp); chart = createChart(dataset); final ChartPanel chartPanel = new ChartPanel(chart); final JPopupMenu popup = new JPopupMenu(); JMenuItem miSave = new JMenuItem(LocalizedStrings.getButton().save(LocalizedStrings.getWbs().timeLine())); miSave.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent arg0) { JFileChooser chooser = new JFileChooser(); chooser.setFileFilter(new ExtensionAndFolderFilter("jpg", "jpeg")); //NON-NLS chooser.setSelectedFile(new File("chart-" //NON-NLS + System.currentTimeMillis() + ".jpg")); int returnVal = chooser.showSaveDialog(reference); if (returnVal == JFileChooser.APPROVE_OPTION) { try { File outfile = chooser.getSelectedFile(); ChartUtilities.saveChartAsJPEG(outfile, chart, chartPanel.getWidth(), chartPanel.getWidth()); Controller.showMessage( LocalizedStrings.getMessages().timeLineSaved(outfile.getCanonicalPath())); } catch (IOException e) { Controller.showError(LocalizedStrings.getErrorMessages().timeLineExportError()); } } } }); popup.add(miSave); chartPanel.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(final MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3) { popup.show(e.getComponent(), e.getX(), e.getY()); } } }); chartPanel.setMinimumDrawHeight(50 + 15 * userWp.size()); chartPanel.setMaximumDrawHeight(50 + 15 * userWp.size()); chartPanel.setMaximumDrawWidth(9999); chartPanel.setPreferredSize( new Dimension((int) chartPanel.getPreferredSize().getWidth(), 50 + 15 * userWp.size())); chartPanel.setPopupMenu(null); this.setLayout(new BorderLayout()); this.removeAll(); JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.weightx = 1; constraints.weighty = 1; constraints.anchor = GridBagConstraints.NORTHWEST; panel.add(chartPanel, constraints); panel.setBackground(Color.white); this.add(panel, BorderLayout.CENTER); GanttRenderer.setDefaultShadowsVisible(false); GanttRenderer.setDefaultBarPainter(new BarPainter() { @Override public void paintBar(final Graphics2D g, final BarRenderer arg1, final int row, final int col, final RectangularShape rect, final RectangleEdge arg5) { String wpName = (String) dataset.getColumnKey(col); int i = 0; int spaceCount = 0; while (wpName.charAt(i++) == ' ' && spaceCount < 17) { spaceCount++; } g.setColor(new Color(spaceCount * 15, spaceCount * 15, spaceCount * 15)); g.fill(rect); g.setColor(Color.black); g.setStroke(new BasicStroke()); g.draw(rect); } @Override public void paintBarShadow(final Graphics2D arg0, final BarRenderer arg1, final int arg2, final int arg3, final RectangularShape arg4, final RectangleEdge arg5, final boolean arg6) { } }); ((CategoryPlot) chart.getPlot()).setRenderer(new GanttRenderer() { private static final long serialVersionUID = -6078915091070733812L; public void drawItem(final Graphics2D g2, final CategoryItemRendererState state, final Rectangle2D dataArea, final CategoryPlot plot, final CategoryAxis domainAxis, final ValueAxis rangeAxis, final CategoryDataset dataset, final int row, final int column, final int pass) { super.drawItem(g2, state, dataArea, plot, domainAxis, rangeAxis, dataset, row, column, pass); } }); }
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. *///w w w. j a va 2 s . c om 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.java.sip.communicator.impl.osdependent.jdic.TrayMenuFactory.java
/** * Creates a tray menu for the given system tray. * * @param tray the system tray for which we're creating a menu * @param swing indicates if we should create a Swing or an AWT menu * @return a tray menu for the given system tray (first) and the default * menu item (second)//from ww w. j av a2 s .co m */ public static Pair<Object, Object> createTrayMenu(SystrayServiceJdicImpl tray, boolean swing, boolean accountMenuSupported) { final Object trayMenu = swing ? new JPopupMenu() : new PopupMenu(); ActionListener listener = new ActionListener() { public void actionPerformed(ActionEvent event) { TrayMenuFactory.actionPerformed(event); } }; Boolean showOptions = OsDependentActivator.getConfigurationService() .getBoolean("net.java.sip.communicator.impl.gui.main.configforms." + "SHOW_OPTIONS_WINDOW", true); if (showOptions.booleanValue()) { add(trayMenu, createTrayMenuItem("settings", (OSUtils.IS_MAC) ? "service.gui.PREFERENCES" : "service.gui.SETTINGS", "service.systray.CONFIGURE_ICON", listener, swing)); } add(trayMenu, createTrayMenuItem("addContact", "service.gui.ADD_CONTACT", "service.gui.icons.ADD_CONTACT_16x16_ICON", listener, swing)); addSeparator(trayMenu); Boolean chatPresenceDisabled = OsDependentActivator.getConfigurationService() .getBoolean("net.java.sip.communicator.impl.gui.main.presence." + "CHAT_PRESENCE_DISABLED", false); if (!chatPresenceDisabled.booleanValue() && accountMenuSupported) { add(trayMenu, new StatusSubMenu(swing, accountMenuSupported).getMenu()); addSeparator(trayMenu); } String showHideName; String showHideTextId; String showHideIconId; if (OsDependentActivator.getUIService().isVisible()) { showHideName = "service.gui.HIDE"; showHideTextId = "service.gui.HIDE"; showHideIconId = "service.gui.icons.SEARCH_ICON_16x16"; } else { showHideName = "service.gui.SHOW"; showHideTextId = "service.gui.SHOW"; showHideIconId = "service.gui.icons.SEARCH_ICON_16x16"; } final Object showHideMenuItem = createTrayMenuItem(showHideName, showHideTextId, showHideIconId, listener, swing); add(trayMenu, showHideMenuItem); add(trayMenu, createTrayMenuItem("service.gui.QUIT", "service.gui.QUIT", "service.systray.QUIT_MENU_ICON", listener, swing)); OsDependentActivator.getUIService().addWindowListener(new WindowAdapter() { /** * Invoked when a window is activated. */ @Override public void windowActivated(WindowEvent e) { changeTrayMenuItem(showHideMenuItem, "service.gui.HIDE", "service.gui.HIDE", "service.gui.icons.SEARCH_ICON_16x16"); } /** * Invoked when a window is de-activated. */ @Override public void windowDeactivated(WindowEvent e) { changeTrayMenuItem(showHideMenuItem, "service.gui.SHOW", "service.gui.SHOW", "service.gui.icons.SEARCH_ICON_16x16"); } }); return Pair.of(trayMenu, showHideMenuItem); }
From source file:de.tntinteractive.portalsammler.gui.DocumentTable.java
private void showPopup(final MouseEvent ev) { final JMenuItem open = new JMenuItem("Anzeigen"); open.addActionListener(new ActionListener() { @Override//from w ww. j a v a 2s . c om public void actionPerformed(final ActionEvent e) { DocumentTable.this.openSelectedRows(); } }); final JMenuItem export = new JMenuItem("Exportieren"); export.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { DocumentTable.this.exportSelectedRows(); } }); final JPopupMenu menu = new JPopupMenu(); menu.add(open); menu.add(export); menu.show(ev.getComponent(), ev.getX(), ev.getY()); }