List of usage examples for javax.swing JRadioButtonMenuItem setActionCommand
public void setActionCommand(String actionCommand)
From source file:com.haskins.cloudtrailviewer.sidebar.EventsStats.java
private void addSourceMenu() { JRadioButtonMenuItem mnuEventName = new JRadioButtonMenuItem("Event Name"); JRadioButtonMenuItem mnuAwsRegion = new JRadioButtonMenuItem("AWS Region"); JRadioButtonMenuItem mnuSourceIpAddress = new JRadioButtonMenuItem("Source IP Address"); JRadioButtonMenuItem mnuUserAgent = new JRadioButtonMenuItem("User Agent"); JRadioButtonMenuItem mnuEventSource = new JRadioButtonMenuItem("Event Source"); JRadioButtonMenuItem mnuErrorCode = new JRadioButtonMenuItem("Error Code"); JRadioButtonMenuItem mnuRecipientAccountId = new JRadioButtonMenuItem("Recipient Account Id"); mnuEventName.setActionCommand("EventName"); mnuEventName.addActionListener(this); mnuEventName.setSelected(true);/* ww w . j a v a 2 s. c o m*/ mnuAwsRegion.setActionCommand("AwsRegion"); mnuAwsRegion.addActionListener(this); mnuSourceIpAddress.setActionCommand("SourceIPAddress"); mnuSourceIpAddress.addActionListener(this); mnuUserAgent.setActionCommand("UserAgent"); mnuUserAgent.addActionListener(this); mnuEventSource.setActionCommand("EventSource"); mnuEventSource.addActionListener(this); mnuErrorCode.setActionCommand("ErrorCode"); mnuErrorCode.addActionListener(this); mnuRecipientAccountId.setActionCommand("RecipientAccountId"); mnuRecipientAccountId.addActionListener(this); sourceGroup.add(mnuEventName); sourceGroup.add(mnuAwsRegion); sourceGroup.add(mnuSourceIpAddress); sourceGroup.add(mnuUserAgent); sourceGroup.add(mnuEventSource); sourceGroup.add(mnuErrorCode); sourceGroup.add(mnuRecipientAccountId); JMenu sourceMenu = new JMenu("Source"); sourceMenu.add(mnuEventName); sourceMenu.add(mnuAwsRegion); sourceMenu.add(mnuSourceIpAddress); sourceMenu.add(mnuUserAgent); sourceMenu.add(mnuEventSource); sourceMenu.add(mnuErrorCode); sourceMenu.add(mnuRecipientAccountId); sourceMenu.add(getUserIdentityMenu(sourceGroup)); menu.add(sourceMenu); }
From source file:eu.apenet.dpt.standalone.gui.DataPreparationToolGUI.java
private void createLanguageMenu() { Locale currentLocale = Locale.getDefault(); ButtonGroup group = new ButtonGroup(); JRadioButtonMenuItem rbMenuItem = new JRadioButtonMenuItem("English"); rbMenuItem.setActionCommand("en"); if (!Arrays.asList(LANGUAGES_OF_TOOL).contains(currentLocale.getLanguage()) || currentLocale.getLanguage().equals("en")) { rbMenuItem.setSelected(true);/* w w w .j a v a 2 s . c o m*/ } rbMenuItem.addActionListener(new LanguageActionListener()); group.add(rbMenuItem); languageMenu.add(rbMenuItem); rbMenuItem = new JRadioButtonMenuItem("Franais"); rbMenuItem.setActionCommand("fr"); if (currentLocale.getLanguage().equals("fr")) { rbMenuItem.setSelected(true); } rbMenuItem.addActionListener(new LanguageActionListener()); group.add(rbMenuItem); languageMenu.add(rbMenuItem); rbMenuItem = new JRadioButtonMenuItem("Deutsch"); rbMenuItem.setActionCommand("de"); if (currentLocale.getLanguage().equals("de")) { rbMenuItem.setSelected(true); } rbMenuItem.addActionListener(new LanguageActionListener()); group.add(rbMenuItem); languageMenu.add(rbMenuItem); rbMenuItem = new JRadioButtonMenuItem(""); rbMenuItem.setActionCommand("el"); if (currentLocale.getLanguage().equals("el")) { rbMenuItem.setSelected(true); } rbMenuItem.addActionListener(new LanguageActionListener()); group.add(rbMenuItem); languageMenu.add(rbMenuItem); rbMenuItem = new JRadioButtonMenuItem("Nederlands"); rbMenuItem.setActionCommand("nl"); if (currentLocale.getLanguage().equals("nl")) { rbMenuItem.setSelected(true); } rbMenuItem.addActionListener(new LanguageActionListener()); group.add(rbMenuItem); languageMenu.add(rbMenuItem); rbMenuItem = new JRadioButtonMenuItem("Magyar"); rbMenuItem.setActionCommand("hu"); if (currentLocale.getLanguage().equals("hu")) { rbMenuItem.setSelected(true); } rbMenuItem.addActionListener(new LanguageActionListener()); group.add(rbMenuItem); languageMenu.add(rbMenuItem); if (Utilities.isDev) { languageMenu.addSeparator(); rbMenuItem = new JRadioButtonMenuItem("XXXXXX"); rbMenuItem.setActionCommand("xx"); if (currentLocale.getLanguage().equals("xx")) { rbMenuItem.setSelected(true); } rbMenuItem.addActionListener(new LanguageActionListener()); group.add(rbMenuItem); languageMenu.add(rbMenuItem); } }
From source file:org.rdv.viz.image.HighResImageViz.java
public void buildPopupMenu(JPopupMenu menu, MouseEvent e) { super.buildPopupMenu(menu, e); ActionListener setTimerangeAction = new ActionListener() { public void actionPerformed(ActionEvent ae) { double newScale = Double.parseDouble(ae.getActionCommand()); setLocalTimescale(newScale); }//from w w w.j a v a 2 s . c om }; // regenerate new menu JMenu timeRangeMenu = new JMenu("Set Timerange"); ButtonGroup timeRangeGroup = new ButtonGroup(); JRadioButtonMenuItem range = new JRadioButtonMenuItem(TimeScale.TIME_SCALE_UNDEFINED_DESC); range.setActionCommand(String.valueOf(TimeScale.TIME_SCALE_UNDEFINED)); range.addActionListener(setTimerangeAction); timeRangeGroup.add(range); timeRangeMenu.add(range); if (localTimeScale_ == TimeScale.TIME_SCALE_UNDEFINED) range.setSelected(true); Double timeScales[] = TimeScale.getGlobalTimeScales(); for (int i = 0; i < timeScales.length; i++) { range = new JRadioButtonMenuItem(DataViewer.formatSeconds(timeScales[i])); range.setActionCommand(String.valueOf(timeScales[i])); range.addActionListener(setTimerangeAction); timeRangeGroup.add(range); timeRangeMenu.add(range); if (localTimeScale_ == timeScales[i]) range.setSelected(true); } menu.add(timeRangeMenu); menu.addSeparator(); // create a popup to copy an image to the clipboard final JMenuItem copyImageMenuItem = new JMenuItem("Copy"); copyImageMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { copyImage(); } }); menu.add(copyImageMenuItem); menu.addSeparator(); // create a popup to save an image final JMenuItem saveImageMenuItem = new JMenuItem("Save as..."); saveImageMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { saveImage(); } }); menu.add(saveImageMenuItem); menu.addSeparator(); // create a popup to copy an image to the clipboard final JMenuItem printImageMenuItem = new JMenuItem("Print..."); printImageMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { printImage(); } }); menu.add(printImageMenuItem); menu.addSeparator(); final JMenuItem zoomInMenuItem = new JMenuItem("Zoom in"); zoomInMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { imagePanel.zoomIn(); } }); menu.add(zoomInMenuItem); final JMenuItem zoomOutMenuItem = new JMenuItem("Zoom out"); zoomOutMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { imagePanel.zoomOut(); } }); menu.add(zoomOutMenuItem); final JSeparator zoomMenuSeparator = new JPopupMenu.Separator(); menu.add(zoomMenuSeparator); final JCheckBoxMenuItem autoScaleMenuItem = new JCheckBoxMenuItem("Auto scale", imagePanel.isAutoScaling()); autoScaleMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { setAutoScale(autoScaleMenuItem.isSelected()); } }); menu.add(autoScaleMenuItem); final JMenuItem resetScaleMenuItem = new JMenuItem("Reset scale"); resetScaleMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { imagePanel.setScale(1); } }); menu.add(resetScaleMenuItem); final JCheckBoxMenuItem showNavigationImageMenuItem = new JCheckBoxMenuItem("Show navigation image", imagePanel.isNavigationImageEnabled()); showNavigationImageMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { setShowNavigationImage(showNavigationImageMenuItem.isSelected()); } }); menu.add(showNavigationImageMenuItem); //menu.addSeparator(); final JCheckBoxMenuItem useThumbnailImageMenuItem = new JCheckBoxMenuItem("Use thumbnail image", useThumbnailImage); useThumbnailImageMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setUseThumbnailImage(useThumbnailImageMenuItem.isSelected()); } }); menu.add(useThumbnailImageMenuItem); boolean hasImage = displayedImageData != null; saveImageMenuItem.setEnabled(hasImage); copyImageMenuItem.setEnabled(hasImage); printImageMenuItem.setEnabled(hasImage); boolean enableZoom = hasImage; zoomInMenuItem.setEnabled(enableZoom); zoomInMenuItem.setVisible(true); zoomOutMenuItem.setEnabled(enableZoom); zoomOutMenuItem.setVisible(true); zoomMenuSeparator.setVisible(true); autoScaleMenuItem.setVisible(true); resetScaleMenuItem.setVisible(true); showNavigationImageMenuItem.setVisible(true); useThumbnailImageMenuItem.setSelected(useThumbnailImage); useThumbnailImageMenuItem.setVisible(imageHasThumbnail()); }