List of usage examples for javax.swing JRadioButtonMenuItem setSelected
public void setSelected(boolean b)
From source file:com.haskins.cloudtrailviewer.sidebar.EventsChart.java
@Override public void addCustomMenu() { 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); 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); customGroup.add(mnuEventName);//from w w w . ja va 2 s . com customGroup.add(mnuAwsRegion); customGroup.add(mnuSourceIpAddress); customGroup.add(mnuUserAgent); customGroup.add(mnuEventSource); customGroup.add(mnuErrorCode); customGroup.add(mnuRecipientAccountId); JMenu sourceMenu = new JMenu("Event"); sourceMenu.add(mnuEventName); sourceMenu.add(mnuAwsRegion); sourceMenu.add(mnuSourceIpAddress); sourceMenu.add(mnuUserAgent); sourceMenu.add(mnuEventSource); sourceMenu.add(mnuErrorCode); sourceMenu.add(mnuRecipientAccountId); sourceMenu.add(getUserIdentityMenu(customGroup)); menu.add(sourceMenu); }
From source file:com.mightypocket.ashot.Mediator.java
private void installListeners() { demon.addTaskListener(new Adapter<Void, ImageEx>() { @Override//from w w w . jav a2 s . com public void process(TaskEvent<List<ImageEx>> event) { List<ImageEx> value = event.getValue(); if (!value.isEmpty()) { final ImageEx img = value.get(0); updateImageProcessor(img); final Image imgp = imageProcessor.process(img.getValue()); showImage(imgp); if (isRecording() && !(p.getBoolean(PREF_SAVE_SKIP_DUPLICATES, true) && img.isDuplicate())) { imageSaver.saveImage((saveOriginal) ? img.getValue() : imgp); } lastImage = img; } else { showImage(generateDummyImage()); } } }); addPropertyChangeListener(PROP_CONNECTED_DEVICE, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { final JRadioButtonMenuItem disconnected = devices.get((String) evt.getOldValue()); final JRadioButtonMenuItem connected = devices.get((String) evt.getNewValue()); if (disconnected != null) { disconnected.setSelected(false); } if (connected != null) { connected.setSelected(true); } else { devicesGroup.clearSelection(); } } }); addPropertyChangeListener(PROP_FULL_SCREEN, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { logger.debug("Full screen: {}", evt.getNewValue()); boolean fs = (Boolean) evt.getNewValue(); presenter = fs ? fullScreenFrame.getPresenter() : mainPanel.getPresenter(); } }); }
From source file:net.sf.jabref.gui.openoffice.OpenOfficePanel.java
private void showSettingsPopup() { JPopupMenu menu = new JPopupMenu(); final JCheckBoxMenuItem autoSync = new JCheckBoxMenuItem( Localization.lang("Automatically sync bibliography when inserting citations"), preferences.syncWhenCiting()); final JRadioButtonMenuItem useActiveBase = new JRadioButtonMenuItem( Localization.lang("Look up BibTeX entries in the active tab only")); final JRadioButtonMenuItem useAllBases = new JRadioButtonMenuItem( Localization.lang("Look up BibTeX entries in all open databases")); final JMenuItem clearConnectionSettings = new JMenuItem(Localization.lang("Clear connection settings")); ButtonGroup bg = new ButtonGroup(); bg.add(useActiveBase);/*from ww w . jav a 2 s. c o m*/ bg.add(useAllBases); if (preferences.useAllDatabases()) { useAllBases.setSelected(true); } else { useActiveBase.setSelected(true); } autoSync.addActionListener(e -> preferences.setSyncWhenCiting(autoSync.isSelected())); useAllBases.addActionListener(e -> preferences.setUseAllDatabases(useAllBases.isSelected())); useActiveBase.addActionListener(e -> preferences.setUseAllDatabases(!useActiveBase.isSelected())); clearConnectionSettings.addActionListener(e -> frame.output(preferences.clearConnectionSettings())); menu.add(autoSync); menu.addSeparator(); menu.add(useActiveBase); menu.add(useAllBases); menu.addSeparator(); menu.add(clearConnectionSettings); menu.show(settingsB, 0, settingsB.getHeight()); }
From source file:burlov.ultracipher.swing.SwingGuiApplication.java
private JMenuBar createMenuBar() { JMenuBar bar = new JMenuBar(); JMenu menu = null;/* w w w . j av a 2 s.c o m*/ /* * 'File' Menue */ menu = new JMenu("File"); menu.setMnemonic(KeyEvent.VK_F); bar.add(menu); JMenuItem item = new JMenuItem("Save database"); item.setAccelerator(KeyStroke.getKeyStroke("control S")); item.setMnemonic(KeyEvent.VK_S); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { saveDatabase(); } }); menu.add(item); item = new JMenuItem("Download database"); item.setMnemonic(KeyEvent.VK_L); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { downloadAndMergeData(); } }); menu.add(item); item = new JMenuItem("Edit sync account"); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { editSyncAccount(); } }); menu.add(item); menu.add(new JSeparator()); JMenu submenu = new JMenu("Import"); menu.add(submenu); item = new JMenuItem("From CSV"); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { importCSV(); } }); submenu.add(item); submenu = new JMenu("Export"); menu.add(submenu); item = new JMenuItem("As CSV"); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { exportCSV(); } }); submenu.add(item); item = new JMenuItem("Change passphrase"); menu.add(item); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { changePassword(); } }); /* * 'Edit' Menue */ menu = new JMenu("Edit"); menu.setMnemonic(KeyEvent.VK_E); bar.add(menu); item = menu.add(mainPanel.getNewEntryAction()); item.setMnemonic(KeyEvent.VK_N); item = menu.add(mainPanel.getDeleteEntryAction()); item.setMnemonic(KeyEvent.VK_D); menu.add(new JSeparator()); menu = new JMenu("Tools"); // item = new JMenuItem("Passwort generator"); // menu.add(item); // item.addActionListener(new ActionListener() { // // @Override // public void actionPerformed(ActionEvent e) { // passGenerator.setVisible(false); // passGenerator.setLocationRelativeTo(getMainFrame()); // passGenerator.setVisible(true); // } // }); item = new JMenuItem("Screen keyboard"); menu.add(item); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { screenKeyboard.setLocationRelativeTo(getMainFrame()); screenKeyboard.setVisible(true); } }); item = new JMenuItem("File digester"); menu.add(item); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { digester.setLocationRelativeTo(getMainFrame()); digester.setVisible(true); } }); bar.add(menu); /* * 'Help' Menue */ menu = new JMenu("Help"); menu.setMnemonic(KeyEvent.VK_H); bar.add(menu); item = new JMenuItem("Performance test"); menu.add(item); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { measurePerformance(); } }); item = new JMenuItem("System info"); menu.add(item); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { showSystemInfo(); } }); item = new JMenuItem("About"); menu.add(item); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String text = "<html>Ultracipher 6.1<br>(C) Copyright 2015 Paul Burlov<br><br>" + "Encryption strength: 768Bit (6 x 128Bit keys)<br>Cipher cascade: AES/Twofish/Serpent/CAST6/SEED/Camellia" + "<br>Encryption mode: Two pass CBC" + "<br>Key derivation algorithm: SCrypt with N=2^14,P=8,R=1<br><br> " + "This product includes software developed by the<br>" + "<ul><li>Apache Software Foundation " + "<a href='http://www.apache.org'>http://www.apache.org</a>" + "<li>Legion of the Bouncy Castle <a href='http://bouncycastle.org/'>http://bouncycastle.org</a>" + "<li>Project SwingX" + "<li>Bytecode Pty Ltd." + "</ul></html>"; JOptionPane.showMessageDialog(getMainFrame(), text, "", JOptionPane.INFORMATION_MESSAGE, getAppIcon()); } }); bar.add(Box.createHorizontalGlue()); menu = new JMenu("Keyboard"); ButtonGroup group = new ButtonGroup(); JRadioButtonMenuItem radioitem = new JRadioButtonMenuItem("System"); radioitem.setSelected(true); group.add(radioitem); radioitem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { translator.resetMapping(); } }); menu.add(radioitem); radioitem = new JRadioButtonMenuItem("Futhark runes"); group.add(radioitem); radioitem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { translator.initForFuthark(); } }); menu.add(radioitem); radioitem = new JRadioButtonMenuItem("Anglo-Saxon runes"); group.add(radioitem); radioitem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { translator.initForAngloSaxon(); } }); menu.add(radioitem); bar.add(menu); // bar.add(Box.createHorizontalGlue()); // bar.add(new PassGeneratorPanel()); return bar; }
From source file:org.eurocarbdb.application.glycoworkbench.plugin.PeakListChartPanel.java
private JPopupMenu createPopupMenu(boolean over_peak) { JPopupMenu menu = new JPopupMenu(); if (over_peak) { updatePeakActions();/*w w w . j ava 2s .c o m*/ ButtonGroup group = new ButtonGroup(); if (shown_mslevel.equals("ms")) { for (GlycanAction a : theApplication.getPluginManager().getMsPeakActions()) { JRadioButtonMenuItem last = new JRadioButtonMenuItem( new GlycanAction(a, "annotatepeaks", -1, "", this)); menu.add(last); last.setSelected(a == ms_action); group.add(last); } } else { for (GlycanAction a : theApplication.getPluginManager().getMsMsPeakActions()) { JRadioButtonMenuItem last = new JRadioButtonMenuItem( new GlycanAction(a, "annotatepeaks", -1, "", this)); menu.add(last); last.setSelected(a == msms_action); group.add(last); } } menu.addSeparator(); } menu.add(theActionManager.get("zoomnone")); menu.add(theActionManager.get("zoomin")); menu.add(theActionManager.get("zoomout")); return menu; }
From source file:net.sf.jabref.openoffice.OpenOfficePanel.java
private void showSettingsPopup() { JPopupMenu menu = new JPopupMenu(); final JCheckBoxMenuItem autoSync = new JCheckBoxMenuItem( Localization.lang("Automatically sync bibliography when inserting citations"), Globals.prefs.getBoolean(JabRefPreferences.SYNC_OO_WHEN_CITING)); final JRadioButtonMenuItem useActiveBase = new JRadioButtonMenuItem( Localization.lang("Look up BibTeX entries in the active tab only")); final JRadioButtonMenuItem useAllBases = new JRadioButtonMenuItem( Localization.lang("Look up BibTeX entries in all open databases")); final JMenuItem clearConnectionSettings = new JMenuItem(Localization.lang("Clear connection settings")); ButtonGroup bg = new ButtonGroup(); bg.add(useActiveBase);/*ww w. j a v a 2 s.com*/ bg.add(useAllBases); if (Globals.prefs.getBoolean(JabRefPreferences.USE_ALL_OPEN_BASES)) { useAllBases.setSelected(true); } else { useActiveBase.setSelected(true); } autoSync.addActionListener( e -> Globals.prefs.putBoolean(JabRefPreferences.SYNC_OO_WHEN_CITING, autoSync.isSelected())); useAllBases.addActionListener( e -> Globals.prefs.putBoolean(JabRefPreferences.USE_ALL_OPEN_BASES, useAllBases.isSelected())); useActiveBase.addActionListener( e -> Globals.prefs.putBoolean(JabRefPreferences.USE_ALL_OPEN_BASES, !useActiveBase.isSelected())); clearConnectionSettings.addActionListener(e -> { Globals.prefs.clear(JabRefPreferences.OO_PATH); Globals.prefs.clear(JabRefPreferences.OO_EXECUTABLE_PATH); Globals.prefs.clear(JabRefPreferences.OO_JARS_PATH); frame.output(Localization.lang("Cleared connection settings.")); }); menu.add(autoSync); menu.addSeparator(); menu.add(useActiveBase); menu.add(useAllBases); menu.addSeparator(); menu.add(clearConnectionSettings); menu.show(settingsB, 0, settingsB.getHeight()); }
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); 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);/*w w w. ja v a 2s. co m*/ 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:net.sf.firemox.AbstractMainForm.java
/** * From the specified MDB file, and the specified radio button menu, we fill * this control with the information read from the MDB file. * /*w w w .j ava 2s. com*/ * @param mdbName * the the MDB file containing the TBS rules * @param itemChck * the radio button representing this TBS */ private void updateMdbMenu(String mdbName, JRadioButtonMenuItem itemChck) { String fullName = null; try { final FileInputStream in = MdbLoader.openMdb(IdConst.TBS_DIR + "/" + mdbName + "/" + mdbName + ".mdb", true); fullName = MToolKit.readString(in); itemChck.setToolTipText("<html><b>" + fullName + "</b> " + MToolKit.readString(in) + "</b> : " + MToolKit.readString(in) + "<br>" + MToolKit.readString(in)); MdbLoader.closeMdb(); } catch (IOException e) { Log.error("The mdb file associated to the TBS '" + mdbName + "' has not been found.\nYou must rebuild this TBS before playing with it"); fullName = "*" + mdbName + " (rebuild it)"; } catch (Throwable e) { Log.error("Exception during the TBS initalisation.\n\tInput file = " + IdConst.TBS_DIR + "/" + mdbName + "/" + mdbName + ".mdb", e); fullName = "*" + mdbName + " (rebuild it)"; } itemChck.setText(fullName); itemChck.setSelected(mdbName.equalsIgnoreCase(MToolKit.tbsName)); }
From source file:com.igormaznitsa.sciareto.ui.MainFrame.java
public MainFrame(@Nonnull @MustNotContainNull final String... args) { super();//from w ww .j a v a2s . c o m initComponents(); this.stackPanel = new JPanel(); this.stackPanel.setFocusable(false); this.stackPanel.setOpaque(false); this.stackPanel.setBorder(BorderFactory.createEmptyBorder(32, 32, 16, 32)); this.stackPanel.setLayout(new BoxLayout(this.stackPanel, BoxLayout.Y_AXIS)); final JPanel glassPanel = (JPanel) this.getGlassPane(); glassPanel.setOpaque(false); this.setGlassPane(glassPanel); glassPanel.setLayout(new BorderLayout(8, 8)); glassPanel.add(Box.createGlue(), BorderLayout.CENTER); final JPanel ppanel = new JPanel(new BorderLayout(0, 0)); ppanel.setFocusable(false); ppanel.setOpaque(false); ppanel.setCursor(null); ppanel.add(this.stackPanel, BorderLayout.SOUTH); glassPanel.add(ppanel, BorderLayout.EAST); this.stackPanel.add(Box.createGlue()); glassPanel.setVisible(false); this.setTitle("Scia Reto"); setIconImage(UiUtils.loadImage("logo256x256.png")); this.stateless = args.length > 0; final MainFrame theInstance = this; this.addWindowListener(new WindowAdapter() { @Override public void windowClosing(@Nonnull final WindowEvent e) { if (doClosing()) { dispose(); } } }); this.tabPane = new EditorTabPane(this); this.explorerTree = new ExplorerTree(this); final JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); splitPane.setOneTouchExpandable(true); splitPane.setDividerLocation(250); splitPane.setResizeWeight(0.0d); splitPane.setLeftComponent(this.explorerTree); splitPane.setRightComponent(this.tabPane); add(splitPane, BorderLayout.CENTER); this.menuOpenRecentProject.addMenuListener(new MenuListener() { @Override public void menuSelected(MenuEvent e) { final File[] lastOpenedProjects = FileHistoryManager.getInstance().getLastOpenedProjects(); if (lastOpenedProjects.length > 0) { for (final File folder : lastOpenedProjects) { final JMenuItem item = new JMenuItem(folder.getName()); item.setToolTipText(folder.getAbsolutePath()); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openProject(folder, false); } }); menuOpenRecentProject.add(item); } } } @Override public void menuDeselected(MenuEvent e) { menuOpenRecentProject.removeAll(); } @Override public void menuCanceled(MenuEvent e) { } }); this.menuOpenRecentFile.addMenuListener(new MenuListener() { @Override public void menuSelected(MenuEvent e) { final File[] lastOpenedFiles = FileHistoryManager.getInstance().getLastOpenedFiles(); if (lastOpenedFiles.length > 0) { for (final File file : lastOpenedFiles) { final JMenuItem item = new JMenuItem(file.getName()); item.setToolTipText(file.getAbsolutePath()); item.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openFileAsTab(file); } }); menuOpenRecentFile.add(item); } } } @Override public void menuDeselected(MenuEvent e) { menuOpenRecentFile.removeAll(); } @Override public void menuCanceled(MenuEvent e) { } }); if (!this.stateless) { restoreState(); } else { boolean openedProject = false; for (final String filePath : args) { final File file = new File(filePath); if (file.isDirectory()) { openedProject = true; openProject(file, true); } else if (file.isFile()) { openFileAsTab(file); } } if (!openedProject) { //TODO try to hide project panel! } } final LookAndFeel current = UIManager.getLookAndFeel(); final ButtonGroup lfGroup = new ButtonGroup(); final String currentLFClassName = current.getClass().getName(); for (final UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { final JRadioButtonMenuItem menuItem = new JRadioButtonMenuItem(info.getName()); lfGroup.add(menuItem); if (currentLFClassName.equals(info.getClassName())) { menuItem.setSelected(true); } menuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(@Nonnull final ActionEvent e) { try { UIManager.setLookAndFeel(info.getClassName()); SwingUtilities.updateComponentTreeUI(theInstance); PreferencesManager.getInstance().getPreferences().put(Main.PROPERTY_LOOKANDFEEL, info.getClassName()); PreferencesManager.getInstance().flush(); } catch (Exception ex) { LOGGER.error("Can't change LF", ex); } } }); this.menuLookAndFeel.add(menuItem); } }
From source file:org.eurocarbdb.application.glycoworkbench.plugin.SpectraPanel.java
private JPopupMenu createPopupMenu(boolean over_peak) { JPopupMenu menu = new JPopupMenu(); if (over_peak) { updatePeakActions();// www. jav a 2 s.com menu.add(theActionManager.get("addpeaks")); ButtonGroup group = new ButtonGroup(); if (shown_mslevel.equals("ms")) { for (GlycanAction a : theApplication.getPluginManager().getMsPeakActions()) { JRadioButtonMenuItem last = new JRadioButtonMenuItem( new GlycanAction(a, "annotatepeaks", -1, "", this)); menu.add(last); last.setSelected(a == ms_action); group.add(last); } } else { for (GlycanAction a : theApplication.getPluginManager().getMsMsPeakActions()) { JRadioButtonMenuItem last = new JRadioButtonMenuItem( new GlycanAction(a, "annotatepeaks", -1, "", this)); menu.add(last); last.setSelected(a == msms_action); group.add(last); } } menu.addSeparator(); } menu.add(theActionManager.get("zoomnone")); menu.add(theActionManager.get("zoomin")); menu.add(theActionManager.get("zoomout")); return menu; }