List of usage examples for javax.swing JMenuItem JMenuItem
public JMenuItem(Action a)
Action
. From source file:net.sf.jhylafax.AbstractQueuePanel.java
public AbstractQueuePanel(String queueName) { this.queueName = queueName; setLayout(new BorderLayout()); setBorder(GUIHelper.createEmptyBorder(10)); resetQueueTableAction = new ResetQueueTableAction(); tablePopupMenu = new JPopupMenu(); TableSorter sorter = new TableSorter(getTableModel()); queueTable = new ColoredTable(sorter); queueTableLayout = new TableLayout(queueTable); initializeTableLayout();/*from www. ja va 2 s .c o m*/ queueTableLayout.getHeaderPopupMenu().add(new JMenuItem(resetQueueTableAction)); add(new JScrollPane(queueTable), BorderLayout.CENTER); queueTable.setShowVerticalLines(true); queueTable.setShowHorizontalLines(false); queueTable.setAutoCreateColumnsFromModel(true); queueTable.setIntercellSpacing(new java.awt.Dimension(2, 1)); queueTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); queueTable.getSelectionModel().addListSelectionListener(this); queueTable.addMouseListener(new PopupListener(tablePopupMenu)); queueTable.setDefaultRenderer(Long.class, new FilesizeCellRenderer()); queueTable.setDefaultRenderer(String.class, new StringCellRenderer()); queueTable.setDefaultRenderer(Date.class, new TimeCellRenderer()); queueTable.setDefaultRenderer(FaxJob.State.class, new StateCellRenderer()); buttonPanel = new JPanel(new FlowLayout()); add(buttonPanel, BorderLayout.SOUTH); }
From source file:it.unibas.spicygui.controllo.provider.MyPopupProviderConnectionInfo.java
private void createPopupMenu() { menu = new JPopupMenu("Popup menu"); JMenuItem item = new JMenuItem(NbBundle.getMessage(Costanti.class, Costanti.HIDE_INFO_CONNECTION)); item.setActionCommand(HIDE_CONNECTION_INFO); item.addActionListener(this); menu.add(item);//from ww w . j a va2 s. co m // menu.addSeparator(); // // JMenuItem item2 = new JMenuItem(NbBundle.getMessage(Costanti.class, Costanti.IMPLIED)); // item2.setActionCommand(SET_IMPLIED); // item2.addActionListener(this); // menu.add(item2); }
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 ww. j av a 2 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:cz.lidinsky.editor.Menu.java
Menu addItem(String text, String actionCommand, ActionListener listener, char mnemonic) { JMenuItem item = new JMenuItem(text); item.setActionCommand(actionCommand); item.addActionListener(listener);// w ww .j av a 2 s . co m item.setMnemonic(mnemonic); JMenu lastMenu = getMenu(getMenuCount() - 1); lastMenu.add(item); return this; }
From source file:gdt.jgui.entity.JEntityStructurePanel.java
/** * The default constructor./* w ww . ja v a 2 s . com*/ */ 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:it.unibas.spicygui.controllo.provider.composition.MyPopupProviderWidgetConstantComposition.java
private void createPopupMenu() { menu = new JPopupMenu("Popup menu"); JMenuItem itemDeleteWidget;/*w w w . j av a2s . c o m*/ itemDeleteWidget = new JMenuItem(NbBundle.getMessage(Costanti.class, Costanti.DELETE_WIDGET_COMPOSITION)); itemDeleteWidget.setActionCommand(DELETE); itemDeleteWidget.addActionListener(this); menu.add(itemDeleteWidget); }
From source file:gdt.jgui.entity.bonddetail.JAddDetailPanel.java
/** * Get context menu./*from w ww . jav a 2 s. co m*/ * @return the context menu. * */ @Override public JMenu getContextMenu() { menu = super.getContextMenu(); mia = null; int cnt = menu.getItemCount(); if (cnt > 0) { mia = new JMenuItem[cnt]; for (int i = 0; i < cnt; i++) mia[i] = menu.getItem(i); } menu.addMenuListener(new MenuListener() { @Override public void menuSelected(MenuEvent e) { menu.removeAll(); if (mia != null) for (JMenuItem mi : mia) try { if (mi != null) menu.add(mi); } catch (Exception ee) { System.out.println("JAddDetailPanel:getConextMenu:" + ee.toString()); } JMenuItem doneItem = new JMenuItem("Done"); doneItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (requesterResponseLocator$ != null) { try { byte[] ba = Base64.decodeBase64(requesterResponseLocator$); String responseLocator$ = new String(ba, "UTF-8"); JConsoleHandler.execute(console, responseLocator$); } catch (Exception ee) { LOGGER.severe(ee.toString()); } } else console.back(); } }); add(doneItem); if (hasSelectedItems()) { addItem = new JMenuItem("Add"); addItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //removeComponents(); } }); menu.add(addItem); } } @Override public void menuDeselected(MenuEvent e) { } @Override public void menuCanceled(MenuEvent e) { } }); return menu; }
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/* w w w .jav a 2 s. co m*/ 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()); }
From source file:fi.elfcloud.client.tree.DataItemNode.java
private void populatePopupMenu(JPopupMenu menu, BeaverGUI gui) { JMenuItem item;/*from ww w.j a v a 2s . c om*/ item = new JMenuItem(Messages.getString("DataItemNode.popup_download")); //$NON-NLS-1$ item.setActionCommand(Integer.toString(gui.ACTION_SAVE_ITEM)); item.addActionListener(gui); item.setIcon(new ImageIcon(BeaverGUI.class.getResource("icons/download16.png"))); //$NON-NLS-1$ menu.add(item); item = new JMenuItem(Messages.getString("DataItemNode.popup_modify")); //$NON-NLS-1$ item.setActionCommand(Integer.toString(gui.ACTION_MODIFY)); item.addActionListener(gui); item.setIcon(new ImageIcon(BeaverGUI.class.getResource("icons/modify_rename16.png"))); //$NON-NLS-1$ menu.add(item); item = new JMenuItem(Messages.getString("DataItemNode.popup_move")); //$NON-NLS-1$ item.setActionCommand(Integer.toString(gui.ACTION_MOVE)); item.setIcon(new ImageIcon(BeaverGUI.class.getResource("icons/move_file16.png"))); //$NON-NLS-1$ item.addActionListener(gui); menu.add(item); item = new JMenuItem(Messages.getString("DataItemNode.popup_information")); //$NON-NLS-1$ item.setIcon(new ImageIcon(BeaverGUI.class.getResource("icons/info_file16.png"))); //$NON-NLS-1$ item.setActionCommand(Integer.toString(gui.ACTION_INFORMATION)); item.addActionListener(gui); menu.add(item); menu.addSeparator(); item = new JMenuItem(Messages.getString("DataItemNode.popup_delete")); //$NON-NLS-1$ item.setActionCommand(Integer.toString(gui.ACTION_DELETE)); item.addActionListener(gui); item.setIcon(new ImageIcon(BeaverGUI.class.getResource("icons/delete16.png"))); //$NON-NLS-1$ menu.add(item); }
From source file:com.choicemaker.cm.modelmaker.gui.utils.HistoChartPanel.java
public HistoChartPanel(final JFreeChart chart, boolean properties, boolean save, boolean print, boolean zoom, boolean tooltips, final ModelMaker modelMaker) { super(chart, properties, save, print, zoom, tooltips); this.modelMaker = modelMaker; // horizontal zoom doesn't work, by setting false we don't get bogus menu item // setHorizontalZoom(false); // setVerticalZoom(true); final JCheckBoxMenuItem logYScale = new JCheckBoxMenuItem( ChoiceMakerCoreMessages.m.formatMessage("train.gui.modelmaker.panel.test.logscale.y")); logYScale.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { CategoryPlot p = (CategoryPlot) chart.getPlot(); Axis oldAxis = p.getRangeAxis(); if (logYScale.isSelected()) { LogarithmicAxis yAxis = new LogarithmicAxis(ChoiceMakerCoreMessages.m .formatMessage("train.gui.modelmaker.panel.histogram.cm.numpairs")); yAxis.setStrictValuesFlag(false); p.setRangeAxis(yAxis);// w w w .j av a 2s. c om } else { p.setRangeAxis(new NumberAxis(ChoiceMakerCoreMessages.m .formatMessage("train.gui.modelmaker.panel.histogram.cm.numpairs"))); } oldAxis.setPlot(null); chartChanged(new ChartChangeEvent(this)); } }); JPopupMenu popup = getPopupMenu(); popup.addSeparator(); popup.add(logYScale); popup.addSeparator(); select = new JMenu("Select"); final JMenuItem all = new JMenuItem("All"); select.add(all); final JMenuItem cmDiffer = new JMenuItem("Human marked differ"); select.add(cmDiffer); final JMenuItem cmHold = new JMenuItem("Human marked hold"); select.add(cmHold); final JMenuItem cmMatch = new JMenuItem("Human marked match"); select.add(cmMatch); ActionListener l = new ActionListener() { public void actionPerformed(ActionEvent ev) { ListeningMarkedRecordPairFilter filter = modelMaker.getFilter(); filter.reset(); filter.setFromPercentage(rangeFrom); filter.setToPercentage(rangeTo); Object src = ev.getSource(); if (src != all) { boolean[] b = new boolean[Decision.NUM_DECISIONS]; if (src == cmDiffer) { b[Decision.DIFFER.toInt()] = true; } else if (src == cmHold) { b[Decision.HOLD.toInt()] = true; } else if (src == cmMatch) { b[Decision.MATCH.toInt()] = true; } filter.setHumanDecision(b); } modelMaker.filterMarkedRecordPairList(); } }; all.addActionListener(l); cmDiffer.addActionListener(l); cmHold.addActionListener(l); cmMatch.addActionListener(l); popup.add(select); addChartMouseListener(new ChartMouseListener() { public void chartMouseClicked(ChartMouseEvent evt) { ChartEntity e = evt.getEntity(); if (e instanceof CategoryItemEntity) { CategoryItemEntity c = (CategoryItemEntity) e; int cat = c.getCategoryIndex(); HistoCategoryDataset data = (HistoCategoryDataset) ((CategoryPlot) getChart().getPlot()) .getDataset(); int len = data.getColumnCount(); float step = 1f / len; rangeFrom = cat * step; rangeTo = rangeFrom + step; ListeningMarkedRecordPairFilter filter = modelMaker.getFilter(); filter.reset(); filter.setFromPercentage(rangeFrom); filter.setToPercentage(rangeTo); boolean[] b = new boolean[Decision.NUM_DECISIONS]; int series = c.getSeries(); if (data.isIncludeHolds() && series != 0) { if (series == 1) { series = 2; } else { series = 1; } } b[series] = true; filter.setHumanDecision(b); modelMaker.filterMarkedRecordPairList(); } } public void chartMouseMoved(ChartMouseEvent arg0) { } }); }