List of usage examples for javax.swing JRadioButtonMenuItem JRadioButtonMenuItem
public JRadioButtonMenuItem(Action a)
Action
supplied. From source file:BeanContainer.java
protected JMenuBar createMenuBar() { JMenuBar menuBar = new JMenuBar(); // w ww. j av a2 s. c o m JMenu mFile = new JMenu("File"); JMenuItem mItem = new JMenuItem("New..."); ActionListener lst = new ActionListener() { public void actionPerformed(ActionEvent e) { Thread newthread = new Thread() { public void run() { String result = (String)JOptionPane.showInputDialog( BeanContainer.this, "Please enter class name to create a new bean", "Input", JOptionPane.INFORMATION_MESSAGE, null, null, m_className); repaint(); if (result==null) return; try { m_className = result; Class cls = Class.forName(result); Object obj = cls.newInstance(); if (obj instanceof Component) { m_activeBean = (Component)obj; m_activeBean.addFocusListener( BeanContainer.this); m_activeBean.requestFocus(); getContentPane().add(m_activeBean); } validate(); } catch (Exception ex) { ex.printStackTrace(); JOptionPane.showMessageDialog( BeanContainer.this, "Error: "+ex.toString(), "Warning", JOptionPane.WARNING_MESSAGE); } } }; newthread.start(); } }; mItem.addActionListener(lst); mFile.add(mItem); mItem = new JMenuItem("Load..."); lst = new ActionListener() { public void actionPerformed(ActionEvent e) { Thread newthread = new Thread() { public void run() { m_chooser.setCurrentDirectory(m_currentDir); m_chooser.setDialogTitle( "Please select file with serialized bean"); int result = m_chooser.showOpenDialog( BeanContainer.this); repaint(); if (result != JFileChooser.APPROVE_OPTION) return; m_currentDir = m_chooser.getCurrentDirectory(); File fChoosen = m_chooser.getSelectedFile(); try { FileInputStream fStream = new FileInputStream(fChoosen); ObjectInput stream = new ObjectInputStream(fStream); Object obj = stream.readObject(); if (obj instanceof Component) { m_activeBean = (Component)obj; m_activeBean.addFocusListener( BeanContainer.this); m_activeBean.requestFocus(); getContentPane().add(m_activeBean); } stream.close(); fStream.close(); validate(); } catch (Exception ex) { ex.printStackTrace(); JOptionPane.showMessageDialog( BeanContainer.this, "Error: "+ex.toString(), "Warning", JOptionPane.WARNING_MESSAGE); } repaint(); } }; newthread.start(); } }; mItem.addActionListener(lst); mFile.add(mItem); mItem = new JMenuItem("Save..."); lst = new ActionListener() { public void actionPerformed(ActionEvent e) { Thread newthread = new Thread() { public void run() { if (m_activeBean == null) return; m_chooser.setDialogTitle( "Please choose file to serialize bean"); m_chooser.setCurrentDirectory(m_currentDir); int result = m_chooser.showSaveDialog( BeanContainer.this); repaint(); if (result != JFileChooser.APPROVE_OPTION) return; m_currentDir = m_chooser.getCurrentDirectory(); File fChoosen = m_chooser.getSelectedFile(); try { FileOutputStream fStream = new FileOutputStream(fChoosen); ObjectOutput stream = new ObjectOutputStream(fStream); stream.writeObject(m_activeBean); stream.close(); fStream.close(); } catch (Exception ex) { ex.printStackTrace(); JOptionPane.showMessageDialog( BeanContainer.this, "Error: "+ex.toString(), "Warning", JOptionPane.WARNING_MESSAGE); } } }; newthread.start(); } }; mItem.addActionListener(lst); mFile.add(mItem); mFile.addSeparator(); mItem = new JMenuItem("Exit"); lst = new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }; mItem.addActionListener(lst); mFile.add(mItem); menuBar.add(mFile); JMenu mEdit = new JMenu("Edit"); mItem = new JMenuItem("Delete"); lst = new ActionListener() { public void actionPerformed(ActionEvent e) { if (m_activeBean == null) return; Object obj = m_editors.get(m_activeBean); if (obj != null) { BeanEditor editor = (BeanEditor)obj; editor.dispose(); m_editors.remove(m_activeBean); } getContentPane().remove(m_activeBean); m_activeBean = null; validate(); repaint(); } }; mItem.addActionListener(lst); mEdit.add(mItem); mItem = new JMenuItem("Properties..."); lst = new ActionListener() { public void actionPerformed(ActionEvent e) { if (m_activeBean == null) return; Object obj = m_editors.get(m_activeBean); if (obj != null) { BeanEditor editor = (BeanEditor)obj; editor.setVisible(true); editor.toFront(); } else { BeanEditor editor = new BeanEditor(m_activeBean); m_editors.put(m_activeBean, editor); } } }; mItem.addActionListener(lst); mEdit.add(mItem); menuBar.add(mEdit); JMenu mLayout = new JMenu("Layout"); ButtonGroup group = new ButtonGroup(); mItem = new JRadioButtonMenuItem("FlowLayout"); mItem.setSelected(true); lst = new ActionListener() { public void actionPerformed(ActionEvent e){ getContentPane().setLayout(new FlowLayout()); validate(); repaint(); } }; mItem.addActionListener(lst); group.add(mItem); mLayout.add(mItem); mItem = new JRadioButtonMenuItem("GridLayout"); lst = new ActionListener() { public void actionPerformed(ActionEvent e){ int col = 3; int row = (int)Math.ceil(getContentPane(). getComponentCount()/(double)col); getContentPane().setLayout(new GridLayout(row, col, 10, 10)); validate(); repaint(); } }; mItem.addActionListener(lst); group.add(mItem); mLayout.add(mItem); mItem = new JRadioButtonMenuItem("BoxLayout - X"); lst = new ActionListener() { public void actionPerformed(ActionEvent e) { getContentPane().setLayout(new BoxLayout( getContentPane(), BoxLayout.X_AXIS)); validate(); repaint(); } }; mItem.addActionListener(lst); group.add(mItem); mLayout.add(mItem); mItem = new JRadioButtonMenuItem("BoxLayout - Y"); lst = new ActionListener() { public void actionPerformed(ActionEvent e) { getContentPane().setLayout(new BoxLayout( getContentPane(), BoxLayout.Y_AXIS)); validate(); repaint(); } }; mItem.addActionListener(lst); group.add(mItem); mLayout.add(mItem); mItem = new JRadioButtonMenuItem("DialogLayout"); lst = new ActionListener() { public void actionPerformed(ActionEvent e) { getContentPane().setLayout(new DialogLayout()); validate(); repaint(); } }; mItem.addActionListener(lst); group.add(mItem); mLayout.add(mItem); menuBar.add(mLayout); return menuBar; }
From source file:net.sf.firemox.Magic.java
/** * Creates new form Magic//from w ww .j ava2s . c om */ private Magic() { super(); initComponents(); // list all installed Look&Feel UIListener uiListener = new UIListener(); UIManager.LookAndFeelInfo[] uimTMP = UIManager.getInstalledLookAndFeels(); final List<Pair<String, String>> lfList = new ArrayList<Pair<String, String>>(); for (LookAndFeelInfo lookAndFeel : uimTMP) { Pair<String, String> info = new Pair<String, String>(lookAndFeel.getName(), lookAndFeel.getClassName()); if (!lfList.contains(info)) { lfList.add(info); } } // list all SkinLF themes final File[] themes = MToolKit.getFile("lib").listFiles(new FileFilter() { public boolean accept(File f) { return f != null && f.getName().endsWith(".zip"); } }); int maxIndex = Configuration.getConfiguration().getMaxIndex("themes.skinlf.caches.cache"); List<Pair<String, String>> knownThemes = new ArrayList<Pair<String, String>>(); for (int i = 0; i < maxIndex + 1; i++) { String file = Configuration.getConfiguration() .getString("themes.skinlf.caches.cache(" + i + ").[@file]"); int index = ArrayUtils.indexOf(themes, MToolKit.getFile(file)); if (index >= 0) { themes[index] = null; Pair<String, String> skin = new Pair<String, String>( Configuration.getConfiguration().getString("themes.skinlf.caches.cache(" + i + ").[@name]"), file); knownThemes.add(skin); lfList.add(skin); } } for (File theme : themes) { if (theme != null) { // a new theme --> will be cached try { final List<Node> properties = new XmlParser().parse(new ZipResourceLoader(theme.toURI().toURL()) .getResourceAsStream("skinlf-themepack.xml")).getNodes("property"); PROPERTIES: for (int j = 0; j < properties.size(); j++) { if ("skin.name".equals(properties.get(j).getAttribute("name"))) { // skin name found String relativePath = MToolKit.getRelativePath(theme.getCanonicalPath()); Pair<String, String> skin = new Pair<String, String>( properties.get(j).getAttribute("value"), "zip:" + relativePath); lfList.add(skin); knownThemes.add(new Pair<String, String>(properties.get(j).getAttribute("value"), relativePath)); break PROPERTIES; } } } catch (Exception e) { Log.error("Error in " + theme, e); } } } Configuration.getConfiguration().clearProperty("themes.skinlf.caches"); for (int index = 0; index < knownThemes.size(); index++) { Pair<String, String> skin = knownThemes.get(index); Configuration.getConfiguration().setProperty("themes.skinlf.caches.cache(" + index + ").[@name]", skin.key); Configuration.getConfiguration().setProperty("themes.skinlf.caches.cache(" + index + ").[@file]", skin.value); } // create look and feel menu items Collections.sort(lfList); lookAndFeels = new JRadioButtonMenuItem[lfList.size() + 1]; ButtonGroup group5 = new ButtonGroup(); for (int i = 0; i < lfList.size(); i++) { final String lfName = lfList.get(i).key; final String lfClassName = lfList.get(i).value; lookAndFeels[i] = new JRadioButtonMenuItem(lfName); if (lookAndFeelName.equalsIgnoreCase(lfClassName)) { // this the current l&f lookAndFeels[i].setSelected(true); } if (!SkinLF.isSkinLF(lfClassName)) { lookAndFeels[i].setEnabled(MToolKit.isAvailableLookAndFeel(lfClassName)); } group5.add(lookAndFeels[i]); lookAndFeels[i].setActionCommand(lfClassName); themeMenu.add(lookAndFeels[i], i); lookAndFeels[i].addActionListener(uiListener); } lfList.clear(); initialdelayMenu.addActionListener(this); dismissdelayMenu.addActionListener(this); ConnectionManager.enableConnectingTools(false); // read auto mana option MCommonVars.autoMana = Configuration.getBoolean("automana", true); autoManaMenu.setSelected(MCommonVars.autoMana); // Force to initialize the TBS settings MToolKit.tbsName = null; setMdb(Configuration.getString("lastTBS", IdConst.TBS_DEFAULT)); // set the autoStack mode MCommonVars.autoStack = Configuration.getBoolean("autostack", false); autoPlayMenu.setSelected(MCommonVars.autoStack); // read maximum displayed colored mana in context PayMana.thresholdColored = Configuration.getInt("threshold-colored", 6); ZoneManager.updateLookAndFeel(); // pack this frame pack(); // Maximize this frame setExtendedState(Frame.MAXIMIZED_BOTH); if (batchMode != -1) { final String deckFile = Configuration.getString(Configuration.getString("decks.deck(0)")); try { Deck batchDeck = DeckReader.getDeck(this, deckFile); switch (batchMode) { case BATCH_SERVER: ConnectionManager.server = new Server(batchDeck, null); ConnectionManager.server.start(); break; case BATCH_CLIENT: ConnectionManager.client = new Client(batchDeck, null); ConnectionManager.client.start(); break; default: } } catch (Throwable e) { throw new RuntimeException("Error in batch mode : ", e); } } }
From source file:com.haskins.cloudtrailviewer.sidebar.EventsChart.java
private JMenu getSessionIssuerMenu(ButtonGroup buttonGroup) { JRadioButtonMenuItem mnuSiType = new JRadioButtonMenuItem("Type"); JRadioButtonMenuItem mnuSiArn = new JRadioButtonMenuItem("Arn"); JRadioButtonMenuItem mnuSiPrincipalId = new JRadioButtonMenuItem("Principal Id"); JRadioButtonMenuItem mnuSiAccountId = new JRadioButtonMenuItem("Account Id"); JRadioButtonMenuItem mnuSiUsername = new JRadioButtonMenuItem("Username"); mnuSiType.setActionCommand("UserIdentity.SessionContext.SessionIssuer.Type"); mnuSiType.addActionListener(this); mnuSiPrincipalId.setActionCommand("UserIdentity.SessionContext.SessionIssuer.PrincipalId"); mnuSiPrincipalId.addActionListener(this); mnuSiArn.setActionCommand("UserIdentity.SessionContext.SessionIssuer.Arn"); mnuSiArn.addActionListener(this); mnuSiAccountId.setActionCommand("UserIdentity.SessionContext.SessionIssuer.AccountId"); mnuSiAccountId.addActionListener(this); mnuSiUsername.setActionCommand("UserIdentity.SessionContext.SessionIssuer.UserName"); mnuSiUsername.addActionListener(this); buttonGroup.add(mnuSiType);// ww w .ja v a 2 s .co m buttonGroup.add(mnuSiPrincipalId); buttonGroup.add(mnuSiArn); buttonGroup.add(mnuSiAccountId); buttonGroup.add(mnuSiUsername); JMenu siMenu = new JMenu("Session Issuer"); siMenu.add(mnuSiType); siMenu.add(mnuSiPrincipalId); siMenu.add(mnuSiArn); siMenu.add(mnuSiAccountId); siMenu.add(mnuSiUsername); return siMenu; }
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);//from ww w. ja v a 2 s . c om 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:com.igormaznitsa.sciareto.ui.MainFrame.java
public MainFrame(@Nonnull @MustNotContainNull final String... args) { super();//from w ww . j av a 2 s. 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.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();// ww w. j a 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:forms.frDados.java
/** * Carrega os temas disponveis e adiciona ao menu de temas. *///from w ww.ja v a 2 s. com private void inicializarTemas() { String winLnF = UIManager.getSystemLookAndFeelClassName(); ButtonGroup group = new ButtonGroup(); for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { JRadioButtonMenuItem mnuItem = new JRadioButtonMenuItem(info.getName()); mnuItem.addActionListener(this); if (winLnF.equals(info.getClassName())) mnuItem.setSelected(true); group.add(mnuItem); mnuTemas.add(mnuItem); } }
From source file:com.haskins.cloudtrailviewer.sidebar.AbstractChart.java
private void addTopMenu() { JRadioButtonMenuItem mnuTop5 = new JRadioButtonMenuItem("Top 5"); JRadioButtonMenuItem mnuTop10 = new JRadioButtonMenuItem("Top 10"); mnuTop5.setActionCommand("top.5"); mnuTop5.addActionListener(this); mnuTop5.setSelected(true);/*from www .j a v a 2s. c o m*/ mnuTop10.setActionCommand("top.10"); mnuTop10.addActionListener(this); topGroup.add(mnuTop5); topGroup.add(mnuTop10); JMenu menuTop = new JMenu("Top"); menuTop.add(mnuTop5); menuTop.add(mnuTop10); menu.add(menuTop); }
From source file:com.haskins.cloudtrailviewer.sidebar.AbstractChart.java
private void addStyleMenu() { JRadioButtonMenuItem mnuPie = new JRadioButtonMenuItem("Pie"); JRadioButtonMenuItem mnuPie3d = new JRadioButtonMenuItem("Pie 3D"); JRadioButtonMenuItem mnuBar = new JRadioButtonMenuItem("Bar"); JRadioButtonMenuItem mnuBar3d = new JRadioButtonMenuItem("Bar 3d"); mnuPie.setActionCommand("style.Pie"); mnuPie.addActionListener(this); mnuPie.setSelected(true);/*from w w w . j ava 2 s . c om*/ mnuPie3d.setActionCommand("style.Pie3d"); mnuPie3d.addActionListener(this); mnuBar.setActionCommand("style.Bar"); mnuBar.addActionListener(this); mnuBar3d.setActionCommand("style.Bar3d"); mnuBar3d.addActionListener(this); styleGroup.add(mnuPie); styleGroup.add(mnuPie3d); styleGroup.add(mnuBar); styleGroup.add(mnuBar3d); JMenu menuStyle = new JMenu("Style"); menuStyle.add(mnuPie); menuStyle.add(mnuPie3d); menuStyle.add(mnuBar); menuStyle.add(mnuBar3d); menu.add(menuStyle); }
From source file:org.eurocarbdb.application.glycoworkbench.plugin.PeakListChartPanel.java
private JPopupMenu createPopupMenu(boolean over_peak) { JPopupMenu menu = new JPopupMenu(); if (over_peak) { updatePeakActions();/*from w w w . ja va2 s .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; }