List of usage examples for javax.swing JRadioButtonMenuItem setSelected
public void setSelected(boolean b)
From source file:org.broad.igv.peaks.PeakTrackMenu.java
public void addDisplayModeItems() { addSeparator();/*from w ww . j a v a 2 s .c om*/ ButtonGroup group = new ButtonGroup(); Track.DisplayMode displayMode = track.getDisplayMode(); JRadioButtonMenuItem m1 = new JRadioButtonMenuItem("Compressed"); m1.setSelected(displayMode == Track.DisplayMode.COLLAPSED); m1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { track.setDisplayMode(Track.DisplayMode.COLLAPSED); IGV.getInstance().doRefresh(); } }); JRadioButtonMenuItem m3 = new JRadioButtonMenuItem("Time Series"); m3.setSelected(displayMode == Track.DisplayMode.EXPANDED); m3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { track.setDisplayMode(Track.DisplayMode.EXPANDED); IGV.getInstance().doRefresh(); } }); add(m1); add(m3); group.add(m1); group.add(m3); }
From source file:MenuTest.java
public MenuFrame() { setTitle("MenuTest"); setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); JMenu fileMenu = new JMenu("File"); fileMenu.add(new TestAction("New")); // demonstrate accelerators JMenuItem openItem = fileMenu.add(new TestAction("Open")); openItem.setAccelerator(KeyStroke.getKeyStroke("ctrl O")); fileMenu.addSeparator();// ww w .jav a 2s . c o m saveAction = new TestAction("Save"); JMenuItem saveItem = fileMenu.add(saveAction); saveItem.setAccelerator(KeyStroke.getKeyStroke("ctrl S")); saveAsAction = new TestAction("Save As"); fileMenu.add(saveAsAction); fileMenu.addSeparator(); fileMenu.add(new AbstractAction("Exit") { public void actionPerformed(ActionEvent event) { System.exit(0); } }); // demonstrate check box and radio button menus readonlyItem = new JCheckBoxMenuItem("Read-only"); readonlyItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { boolean saveOk = !readonlyItem.isSelected(); saveAction.setEnabled(saveOk); saveAsAction.setEnabled(saveOk); } }); ButtonGroup group = new ButtonGroup(); JRadioButtonMenuItem insertItem = new JRadioButtonMenuItem("Insert"); insertItem.setSelected(true); JRadioButtonMenuItem overtypeItem = new JRadioButtonMenuItem("Overtype"); group.add(insertItem); group.add(overtypeItem); // demonstrate icons Action cutAction = new TestAction("Cut"); cutAction.putValue(Action.SMALL_ICON, new ImageIcon("cut.gif")); Action copyAction = new TestAction("Copy"); copyAction.putValue(Action.SMALL_ICON, new ImageIcon("copy.gif")); Action pasteAction = new TestAction("Paste"); pasteAction.putValue(Action.SMALL_ICON, new ImageIcon("paste.gif")); JMenu editMenu = new JMenu("Edit"); editMenu.add(cutAction); editMenu.add(copyAction); editMenu.add(pasteAction); // demonstrate nested menus JMenu optionMenu = new JMenu("Options"); optionMenu.add(readonlyItem); optionMenu.addSeparator(); optionMenu.add(insertItem); optionMenu.add(overtypeItem); editMenu.addSeparator(); editMenu.add(optionMenu); // demonstrate mnemonics JMenu helpMenu = new JMenu("Help"); helpMenu.setMnemonic('H'); JMenuItem indexItem = new JMenuItem("Index"); indexItem.setMnemonic('I'); helpMenu.add(indexItem); // you can also add the mnemonic key to an action Action aboutAction = new TestAction("About"); aboutAction.putValue(Action.MNEMONIC_KEY, new Integer('A')); helpMenu.add(aboutAction); // add all top-level menus to menu bar JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); menuBar.add(fileMenu); menuBar.add(editMenu); menuBar.add(helpMenu); // demonstrate pop-ups popup = new JPopupMenu(); popup.add(cutAction); popup.add(copyAction); popup.add(pasteAction); JPanel panel = new JPanel(); panel.setComponentPopupMenu(popup); add(panel); // the following line is a workaround for bug 4966109 panel.addMouseListener(new MouseAdapter() { }); }
From source file:de.burrotinto.jKabel.dispalyAS.DisplayAAS.java
private JMenu getjTypSortMenu() { JMenu typSortMenu = new JMenu("Typ Sortierung"); JRadioButtonMenuItem inOrder = new JRadioButtonMenuItem("Aufsteigend Sortieren"); inOrder.setSelected(ConfigReader.getInstance().isTypeInOrder()); inOrder.addActionListener(new ActionListener() { @Override/*w w w . java 2s .c o m*/ public void actionPerformed(ActionEvent actionEvent) { try { ConfigReader.getInstance().setTypeInOrder(inOrder.isSelected()); // if (kabelTypAuswahlAAS != null) { // kabelTypAuswahlAAS.typSelected(kabelTypAuswahlAAS.getSelected()); // } } catch (IOException e) { e.printStackTrace(); } } }); typSortMenu.add(inOrder); typSortMenu.addSeparator(); ButtonGroup group = new ButtonGroup(); for (AbstractTypeSort aTS : ConfigReader.getInstance().getAllTypSort()) { JRadioButtonMenuItem sw = new JRadioButtonMenuItem(aTS.getName()); sw.setSelected(aTS.equals(ConfigReader.getInstance().getKabeltypSort())); group.add(sw); typSortMenu.add(sw); sw.addActionListener(aTS); } return typSortMenu; }
From source file:de.burrotinto.jKabel.dispalyAS.DisplayAAS.java
private JMenu getjTrommelSortMenu() { JMenu trommelSortMenu = new JMenu("Trommel Sortierung"); JRadioButtonMenuItem inOrder = new JRadioButtonMenuItem("Aufsteigend Sortieren"); inOrder.setSelected(ConfigReader.getInstance().isTypeInOrder()); inOrder.addActionListener(new ActionListener() { @Override/*w w w. j a v a2 s . com*/ public void actionPerformed(ActionEvent actionEvent) { try { ConfigReader.getInstance().setTrommelInOrder(inOrder.isSelected()); // if (kabelTypAuswahlAAS != null) { // kabelTypAuswahlAAS.typSelected(kabelTypAuswahlAAS.getSelected()); // } } catch (IOException e) { e.printStackTrace(); } } }); trommelSortMenu.add(inOrder); trommelSortMenu.addSeparator(); ButtonGroup group = new ButtonGroup(); for (AbstractTrommelSort aTS : ConfigReader.getInstance().getAllTrommelSort()) { JRadioButtonMenuItem sw = new JRadioButtonMenuItem(aTS.getName()); sw.setSelected(aTS.equals(ConfigReader.getInstance().getTrommelSort())); group.add(sw); trommelSortMenu.add(sw); sw.addActionListener(aTS); } return trommelSortMenu; }
From source file:it.cnr.icar.eric.client.ui.swing.metal.MetalThemeMenu.java
/** * Constucts a JMenu named 'name' with a a RadioButton for each * object in 'themeArray'.//from w w w . j av a 2 s.co m * * @param name the visible name for the Menu. * @param themeArray the array of themes to put in the menu. */ public MetalThemeMenu(String name, MetalTheme[] themeArray) { super(name); themeNames = ResourceBundle.getBundle(BASE_NAME, Locale.getDefault()); themes = themeArray; ButtonGroup group = new ButtonGroup(); JRadioButtonMenuItem defaultItem = null; for (int i = 0; i < themes.length; i++) { String themeName; try { themeName = themeNames.getString(themes[i].getName().replaceAll("\\s", "")); } catch (MissingResourceException mre) { themeName = themes[i].getName(); Object[] noResourceArgs = { themes[i].getName(), getLocale() }; MessageFormat form = new MessageFormat(themeNames.getString("message.error.noResource")); log.error(form.format(noResourceArgs)); } JRadioButtonMenuItem item = new JRadioButtonMenuItem(themeName); group.add(item); add(item); item.setActionCommand(i + ""); item.addActionListener(this); // Theme name without spaces is the key for looking up localized item text. item.setName(themes[i].getName().replaceAll(" ", "")); if (i == 0) { item.setSelected(true); defaultItem = item; } } //add listener for 'locale' bound property RegistryBrowser.getInstance().addPropertyChangeListener(RegistryBrowser.PROPERTY_LOCALE, this); defaultItem.doClick(); }
From source file:net.sf.firemox.AbstractMainForm.java
/** * Initialize the components of this form. *//* w ww .j a va2 s. c o m*/ protected void initAbstractMenu() { // "TBS" menu tbsMenu = UIHelper.buildMenu("menu_options_tbs"); ButtonGroup group4 = new ButtonGroup(); final MdbListener mdbListener = new MdbListener(this); final File[] mdbs = MToolKit.getFile(IdConst.TBS_DIR) .listFiles((FileFilter) FileFilterUtils.suffixFileFilter("xml")); String defaultTbs = MToolKit.tbsName; for (File mdb : mdbs) { String mdbName = FilenameUtils.getBaseName(mdb.getName()); JRadioButtonMenuItem itemChck = new JRadioButtonMenuItem(); MToolKit.tbsName = mdbName; updateMdbMenu(mdbName, itemChck); itemChck.setActionCommand(mdbName); itemChck.setFont(MToolKit.defaultFont); itemChck.addActionListener(mdbListener); group4.add(itemChck); tbsMenu.add(itemChck); if (mdbName.equals(defaultTbs)) { itemChck.setSelected(true); } } MToolKit.tbsName = defaultTbs; tbsMenu.add(new JSeparator()); // "More TBS" menu item tbsMenu.add(UIHelper.buildMenu("menu_options_tbs_more", mdbListener)); tbsMenu.add(new JSeparator()); final JMenuItem updateMdbMenu = UIHelper.buildMenu("menu_options_tbs_update", mdbListener); updateMdbMenu.setEnabled(false); tbsMenu.add(updateMdbMenu); tbsMenu.add(UIHelper.buildMenu("menu_options_tbs_rebuild", mdbListener)); optionMenu.add(new JSeparator()); optionMenu.add(tbsMenu); }
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); mnuTop10.setActionCommand("top.10"); mnuTop10.addActionListener(this); topGroup.add(mnuTop5);// w w w. ja v a 2 s .c o m 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 addOrientationMenu() { JRadioButtonMenuItem mnuHorizontal = new JRadioButtonMenuItem("Horizontal"); JRadioButtonMenuItem mnuVertical = new JRadioButtonMenuItem("Vertical"); mnuHorizontal.setActionCommand("orientation.horizontal"); mnuHorizontal.addActionListener(this); mnuHorizontal.setSelected(true); mnuVertical.setActionCommand("orientation.vertical"); mnuVertical.addActionListener(this); orientationGroup.add(mnuHorizontal); orientationGroup.add(mnuVertical);//from ww w . ja v a2s.c o m JMenu menuOrientation = new JMenu("Orientation"); menuOrientation.add(mnuHorizontal); menuOrientation.add(mnuVertical); menu.add(menuOrientation); }
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); mnuPie3d.setActionCommand("style.Pie3d"); mnuPie3d.addActionListener(this); mnuBar.setActionCommand("style.Bar"); mnuBar.addActionListener(this); mnuBar3d.setActionCommand("style.Bar3d"); mnuBar3d.addActionListener(this); styleGroup.add(mnuPie);/*from w w w. ja v a 2s. c om*/ 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.AnnotationReportApplet.java
private JMenu createViewMenu() { GraphicOptions view_opt = theCanvas.getWorkspace().getGraphicOptions(); JMenu view_menu = new JMenu("View"); view_menu.setMnemonic(KeyEvent.VK_V); // zoom /*from www.j av a 2 s .c om*/ view_menu.add(theActionManager.get("zoomnone")); view_menu.add(theActionManager.get("zoomin")); view_menu.add(theActionManager.get("zoomout")); view_menu.addSeparator(); // notation JRadioButtonMenuItem last = null; ButtonGroup groupn = new ButtonGroup(); view_menu.add( last = new JRadioButtonMenuItem(theActionManager.get("notation=" + GraphicOptions.NOTATION_CFG))); last.setSelected(view_opt.NOTATION.equals(GraphicOptions.NOTATION_CFG)); groupn.add(last); view_menu.add( last = new JRadioButtonMenuItem(theActionManager.get("notation=" + GraphicOptions.NOTATION_CFGBW))); last.setSelected(view_opt.NOTATION.equals(GraphicOptions.NOTATION_CFGBW)); groupn.add(last); view_menu.add(last = new JRadioButtonMenuItem( theActionManager.get("notation=" + GraphicOptions.NOTATION_CFGLINK))); last.setSelected(view_opt.NOTATION.equals(GraphicOptions.NOTATION_CFGLINK)); groupn.add(last); view_menu.add( last = new JRadioButtonMenuItem(theActionManager.get("notation=" + GraphicOptions.NOTATION_UOXF))); last.setSelected(view_opt.NOTATION.equals(GraphicOptions.NOTATION_UOXF)); groupn.add(last); view_menu.add( last = new JRadioButtonMenuItem(theActionManager.get("notation=" + GraphicOptions.NOTATION_TEXT))); last.setSelected(view_opt.NOTATION.equals(GraphicOptions.NOTATION_TEXT)); groupn.add(last); view_menu.addSeparator(); // display display_button_group = new ButtonGroup(); display_models = new HashMap<String, ButtonModel>(); view_menu.add( last = new JRadioButtonMenuItem(theActionManager.get("display=" + GraphicOptions.DISPLAY_COMPACT))); last.setSelected(view_opt.DISPLAY.equals(GraphicOptions.DISPLAY_COMPACT)); display_models.put(GraphicOptions.DISPLAY_COMPACT, last.getModel()); display_button_group.add(last); view_menu.add( last = new JRadioButtonMenuItem(theActionManager.get("display=" + GraphicOptions.DISPLAY_NORMAL))); last.setSelected(view_opt.DISPLAY.equals(GraphicOptions.DISPLAY_NORMAL)); display_models.put(GraphicOptions.DISPLAY_NORMAL, last.getModel()); display_button_group.add(last); view_menu.add(last = new JRadioButtonMenuItem( theActionManager.get("display=" + GraphicOptions.DISPLAY_NORMALINFO))); last.setSelected(view_opt.DISPLAY.equals(GraphicOptions.DISPLAY_NORMALINFO)); display_models.put(GraphicOptions.DISPLAY_NORMALINFO, last.getModel()); display_button_group.add(last); view_menu.add( last = new JRadioButtonMenuItem(theActionManager.get("display=" + GraphicOptions.DISPLAY_CUSTOM))); last.setSelected(view_opt.DISPLAY.equals(GraphicOptions.DISPLAY_CUSTOM)); display_models.put(GraphicOptions.DISPLAY_CUSTOM, last.getModel()); display_button_group.add(last); //view_menu.add( lastcb = new JCheckBoxMenuItem(theActionManager.get("showinfo")) ); //lastcb.setState(view_opt.SHOW_INFO); view_menu.addSeparator(); // orientation view_menu.add(theActionManager.get("orientation")); view_menu.addSeparator(); view_menu.add(theActionManager.get("displaysettings")); view_menu.add(theActionManager.get("reportsettings")); return view_menu; }