List of usage examples for javax.swing JMenuItem setActionCommand
public void setActionCommand(String actionCommand)
From source file:it.unibas.spicygui.controllo.provider.MyPopupProviderJoinCondition.java
private void createPopupMenu() { bindingGroup = new BindingGroup(); menu = new JPopupMenu("Popup menu"); JMenuItem item1; JCheckBoxMenuItem item2;// www.ja v a2 s.co m JCheckBoxMenuItem item3; JCheckBoxMenuItem item4; item1 = new JMenuItem(NbBundle.getMessage(Costanti.class, Costanti.GENERIC_DELETE)); item1.setActionCommand(DELETE); item1.addActionListener(this); item2 = new JCheckBoxMenuItem(NbBundle.getMessage(Costanti.class, Costanti.TOGGLE_MANDATORY)); Binding binding = Bindings.createAutoBinding(AutoBinding.UpdateStrategy.READ, joinCondition, ELProperty.create("${mandatory}"), item2, BeanProperty.create("selected")); bindingGroup.addBinding(binding); item2.setActionCommand(TOGGLE_MANDATORY); item2.addActionListener(this); item3 = new JCheckBoxMenuItem(NbBundle.getMessage(Costanti.class, Costanti.TOGGLE_FOREIGN)); Binding binding2 = Bindings.createAutoBinding(AutoBinding.UpdateStrategy.READ, joinCondition, ELProperty.create("${monodirectional}"), item3, BeanProperty.create("selected")); bindingGroup.addBinding(binding2); item3.setActionCommand(TOGGLE_FOREIGN); item3.addActionListener(this); item4 = new JCheckBoxMenuItem(NbBundle.getMessage(Costanti.class, Costanti.TOGGLE_MATCH_STRING)); Binding binding3 = Bindings.createAutoBinding(AutoBinding.UpdateStrategy.READ, joinCondition, ELProperty.create("${matchString}"), item4, BeanProperty.create("selected")); bindingGroup.addBinding(binding3); item4.setActionCommand(TOGGLE_MATCH_STRING); item4.addActionListener(this); menu.add(item1); menu.add(item2); menu.add(item3); menu.add(item4); bindingGroup.bind(); }
From source file:net.sf.mzmine.modules.visualization.twod.TwoDPlot.java
TwoDPlot(RawDataFile rawDataFile, TwoDVisualizerWindow visualizer, TwoDDataSet dataset, Range rtRange, Range mzRange) {/*from w w w. j a v a 2 s . c o m*/ super(null, true); this.rawDataFile = rawDataFile; this.rtRange = rtRange; this.mzRange = mzRange; setBackground(Color.white); setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); // set the X axis (retention time) properties xAxis = new NumberAxis("Retention time"); xAxis.setAutoRangeIncludesZero(false); xAxis.setNumberFormatOverride(rtFormat); xAxis.setUpperMargin(0); xAxis.setLowerMargin(0); // set the Y axis (intensity) properties yAxis = new NumberAxis("m/z"); yAxis.setAutoRangeIncludesZero(false); yAxis.setNumberFormatOverride(mzFormat); yAxis.setUpperMargin(0); yAxis.setLowerMargin(0); // set the plot properties plot = new TwoDXYPlot(dataset, rtRange, mzRange, xAxis, yAxis); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); // chart properties chart = new JFreeChart("", titleFont, plot, false); chart.setBackgroundPaint(Color.white); setChart(chart); // title chartTitle = chart.getTitle(); chartTitle.setMargin(5, 0, 0, 0); chartTitle.setFont(titleFont); chartSubTitle = new TextTitle(); chartSubTitle.setFont(subTitleFont); chartSubTitle.setMargin(5, 0, 0, 0); chart.addSubtitle(chartSubTitle); // disable maximum size (we don't want scaling) setMaximumDrawWidth(Integer.MAX_VALUE); setMaximumDrawHeight(Integer.MAX_VALUE); // set crosshair (selection) properties plot.setRangeCrosshairVisible(false); plot.setDomainCrosshairVisible(true); plot.setDomainCrosshairPaint(crossHairColor); plot.setDomainCrosshairStroke(crossHairStroke); // set rendering order plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); peakDataRenderer = new PeakDataRenderer(); JMenuItem plotTypeMenuItem = new JMenuItem("Toggle centroid/continuous mode"); plotTypeMenuItem.addActionListener(visualizer); plotTypeMenuItem.setActionCommand("SWITCH_PLOTMODE"); add(plotTypeMenuItem); JPopupMenu popupMenu = getPopupMenu(); popupMenu.addSeparator(); popupMenu.add(plotTypeMenuItem); }
From source file:net.sf.mzmine.modules.visualization.neutralloss.NeutralLossPlot.java
NeutralLossPlot(NeutralLossVisualizerWindow visualizer, NeutralLossDataSet dataset, Object xAxisType) { super(null, true); this.visualizer = visualizer; setBackground(Color.white);/* w ww . j a v a 2 s . c o m*/ setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); NumberFormat rtFormat = MZmineCore.getConfiguration().getRTFormat(); NumberFormat mzFormat = MZmineCore.getConfiguration().getMZFormat(); // set the X axis (retention time) properties NumberAxis xAxis; if (xAxisType.equals(NeutralLossParameters.xAxisPrecursor)) { xAxis = new NumberAxis("Precursor m/z"); xAxis.setNumberFormatOverride(mzFormat); } else { xAxis = new NumberAxis("Retention time"); xAxis.setNumberFormatOverride(rtFormat); } xAxis.setUpperMargin(0); xAxis.setLowerMargin(0); xAxis.setAutoRangeIncludesZero(false); // set the Y axis (intensity) properties NumberAxis yAxis = new NumberAxis("Neutral loss (Da)"); yAxis.setAutoRangeIncludesZero(false); yAxis.setNumberFormatOverride(mzFormat); yAxis.setUpperMargin(0); yAxis.setLowerMargin(0); // set the renderer properties defaultRenderer = new NeutralLossDataPointRenderer(false, true); defaultRenderer.setTransparency(0.4f); setSeriesColorRenderer(0, pointColor, dataPointsShape); setSeriesColorRenderer(1, searchPrecursorColor, dataPointsShape2); setSeriesColorRenderer(2, searchNeutralLossColor, dataPointsShape2); // tooltips defaultRenderer.setBaseToolTipGenerator(dataset); // set the plot properties plot = new XYPlot(dataset, xAxis, yAxis, defaultRenderer); plot.setBackgroundPaint(Color.white); plot.setRenderer(defaultRenderer); plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD); // chart properties chart = new JFreeChart("", titleFont, plot, false); chart.setBackgroundPaint(Color.white); setChart(chart); // title chartTitle = chart.getTitle(); chartTitle.setMargin(5, 0, 0, 0); chartTitle.setFont(titleFont); // disable maximum size (we don't want scaling) setMaximumDrawWidth(Integer.MAX_VALUE); setMaximumDrawHeight(Integer.MAX_VALUE); // set crosshair (selection) properties plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.setDomainCrosshairPaint(crossHairColor); plot.setRangeCrosshairPaint(crossHairColor); plot.setDomainCrosshairStroke(crossHairStroke); plot.setRangeCrosshairStroke(crossHairStroke); plot.addRangeMarker(new ValueMarker(0)); // set focusable state to receive key events setFocusable(true); // register key handlers GUIUtils.registerKeyHandler(this, KeyStroke.getKeyStroke("SPACE"), visualizer, "SHOW_SPECTRUM"); // add items to popup menu JPopupMenu popupMenu = getPopupMenu(); popupMenu.addSeparator(); JMenuItem highLightPrecursorRange = new JMenuItem("Highlight precursor m/z range..."); highLightPrecursorRange.addActionListener(visualizer); highLightPrecursorRange.setActionCommand("HIGHLIGHT_PRECURSOR"); popupMenu.add(highLightPrecursorRange); JMenuItem highLightNeutralLossRange = new JMenuItem("Highlight neutral loss m/z range..."); highLightNeutralLossRange.addActionListener(visualizer); highLightNeutralLossRange.setActionCommand("HIGHLIGHT_NEUTRALLOSS"); popupMenu.add(highLightNeutralLossRange); }
From source file:be.fedict.eid.tsl.tool.TslTool.java
private JMenuItem addActionMenuItem(String text, int mnemonic, String actionCommand, JMenu menu, boolean enabled) { JMenuItem menuItem = new JMenuItem(text); menuItem.setMnemonic(mnemonic);/* w w w . j a va 2 s . co m*/ menuItem.setActionCommand(actionCommand); menuItem.addActionListener(this); menuItem.setEnabled(enabled); menu.add(menuItem); return menuItem; }
From source file:org.jfree.chart.demo.JFreeChartDemo.java
/** * Creates a menubar.//from w w w . java2 s. c om * * @param resources localised resources. * * @return the menu bar. */ private JMenuBar createMenuBar(final ResourceBundle resources) { // create the menus final JMenuBar menuBar = new JMenuBar(); String label; Character mnemonic; // first the file menu label = resources.getString("menu.file"); mnemonic = (Character) resources.getObject("menu.file.mnemonic"); final JMenu fileMenu = new JMenu(label, true); fileMenu.setMnemonic(mnemonic.charValue()); label = resources.getString("menu.file.exit"); mnemonic = (Character) resources.getObject("menu.file.exit.mnemonic"); final JMenuItem exitItem = new JMenuItem(label, mnemonic.charValue()); exitItem.setActionCommand(EXIT_COMMAND); exitItem.addActionListener(this); fileMenu.add(exitItem); // then the help menu label = resources.getString("menu.help"); mnemonic = (Character) resources.getObject("menu.help.mnemonic"); final JMenu helpMenu = new JMenu(label); helpMenu.setMnemonic(mnemonic.charValue()); label = resources.getString("menu.help.about"); mnemonic = (Character) resources.getObject("menu.help.about.mnemonic"); final JMenuItem aboutItem = new JMenuItem(label, mnemonic.charValue()); aboutItem.setActionCommand(ABOUT_COMMAND); aboutItem.addActionListener(this); helpMenu.add(aboutItem); // finally, glue together the menu and return it menuBar.add(fileMenu); menuBar.add(helpMenu); return menuBar; }
From source file:edu.wisc.ssec.mcidasv.control.McIDASVHistogramWrapper.java
/** * Add the default menu items//from w w w .ja va 2s. c o m * * @param items List of menu items * * @return The items list */ @Override protected List getPopupMenuItems(List items) { items = super.getPopupMenuItems(items); for (Object o : items) { if (o instanceof JMenuItem) { JMenuItem menuItem = (JMenuItem) o; if ("Properties...".equals(menuItem.getText())) { menuItem.setActionCommand(ChartPanel.PROPERTIES_COMMAND); menuItem.addActionListener(buildHistoPropsListener()); } } } return items; }
From source file:SwingTest.java
/** * Helper method to creates a Swing JMenuItem. *///from w w w . j a v a2 s. co m private JMenuItem createMenuItem(String menuText, String buttonText, ActionListener listener) { JMenuItem menuItem = new JMenuItem(buttonText); menuItem.addActionListener(listener); menuItem.setActionCommand(menuText + "|" + buttonText); return menuItem; }
From source file:ListCutPaste.java
/** * Create an Edit menu to support cut/copy/paste. *//*from w ww. j a va 2 s . co m*/ public JMenuBar createMenuBar() { JMenuItem menuItem = null; JMenuBar menuBar = new JMenuBar(); JMenu mainMenu = new JMenu("Edit"); mainMenu.setMnemonic(KeyEvent.VK_E); TransferActionListener actionListener = new TransferActionListener(); menuItem = new JMenuItem("Cut"); menuItem.setActionCommand((String) TransferHandler.getCutAction().getValue(Action.NAME)); menuItem.addActionListener(actionListener); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, ActionEvent.CTRL_MASK)); menuItem.setMnemonic(KeyEvent.VK_T); mainMenu.add(menuItem); menuItem = new JMenuItem("Copy"); menuItem.setActionCommand((String) TransferHandler.getCopyAction().getValue(Action.NAME)); menuItem.addActionListener(actionListener); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.CTRL_MASK)); menuItem.setMnemonic(KeyEvent.VK_C); mainMenu.add(menuItem); menuItem = new JMenuItem("Paste"); menuItem.setActionCommand((String) TransferHandler.getPasteAction().getValue(Action.NAME)); menuItem.addActionListener(actionListener); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, ActionEvent.CTRL_MASK)); menuItem.setMnemonic(KeyEvent.VK_P); mainMenu.add(menuItem); menuBar.add(mainMenu); return menuBar; }
From source file:it.unibas.spicygui.controllo.provider.MyPopupProviderConnectionMappingTask.java
private void createPopupMenu() { menu = new JPopupMenu("Popup menu"); JMenuItem item; // item = new JMenuItem(NbBundle.getMessage(Costanti.class, Costanti.SHOW_HIDE_INFO_CONNECTION)); // item.setActionCommand(SHOW); // item.addActionListener(this); // menu.add(item); itemConfidence = new JMenuItem(); menu.add(itemConfidence);/*from www. ja v a2 s .com*/ itemImplied = new JCheckBoxMenuItem(); menu.add(itemImplied); item = new JMenuItem(NbBundle.getMessage(Costanti.class, Costanti.DELETE_CONNECTION)); item.setActionCommand(DELETE); item.addActionListener(this); menu.add(item); }
From source file:ucar.unidata.idv.control.McVHistogramWrapper.java
/** * Add the default menu items//from w w w. j av a 2 s . com * * @param items List of menu items * * @return The items list */ @Override public List getPopupMenuItems(List items) { items = super.getPopupMenuItems(items); for (Object o : items) { if (o instanceof JMenuItem) { JMenuItem menuItem = (JMenuItem) o; if ("Properties...".equals(menuItem.getText())) { if (menuItem.getActionListeners().length == 0) { menuItem.setActionCommand(ChartPanel.PROPERTIES_COMMAND); menuItem.addActionListener(buildHistoPropsListener()); } } } } return items; }