Java Code Examples for javax.swing.JRadioButtonMenuItem#setSelected()
The following examples show how to use
javax.swing.JRadioButtonMenuItem#setSelected() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ComponentSource.java From LoboBrowser with MIT License | 6 votes |
private void populateSearchers() { final JMenu searchersMenu = this.searchersMenu; searchersMenu.removeAll(); final ToolsSettings settings = ToolsSettings.getInstance(); final Collection<SearchEngine> searchEngines = settings.getSearchEngines(); final SearchEngine selectedEngine = settings.getSelectedSearchEngine(); if (searchEngines != null) { for (final SearchEngine se : searchEngines) { final SearchEngine finalSe = se; final JRadioButtonMenuItem item = new JRadioButtonMenuItem(); item.setAction(new AbstractAction() { private static final long serialVersionUID = -3263394523150719487L; public void actionPerformed(final ActionEvent e) { settings.setSelectedSearchEngine(finalSe); settings.save(); ComponentSource.this.updateSearchButtonTooltip(); } }); item.setSelected(se == selectedEngine); item.setText(se.getName()); item.setToolTipText(se.getDescription()); searchersMenu.add(item); } } }
Example 2
Source File: MainFrame.java From android-screen-monitor with Apache License 2.0 | 6 votes |
private void addRadioButtonMenuItemZoom( JMenu menuZoom, ButtonGroup buttonGroup, final double zoom, String caption, int nemonic, double currentZoom) { JRadioButtonMenuItem radioButtonMenuItemZoom = new JRadioButtonMenuItem(caption); if (nemonic != -1) { radioButtonMenuItemZoom.setMnemonic(nemonic); } radioButtonMenuItemZoom.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setZoom(zoom); } }); if (currentZoom == zoom) { radioButtonMenuItemZoom.setSelected(true); } buttonGroup.add(radioButtonMenuItemZoom); menuZoom.add(radioButtonMenuItemZoom); }
Example 3
Source File: MetalThemeMenu.java From hottub with GNU General Public License v2.0 | 6 votes |
@SuppressWarnings("LeakingThisInConstructor") public MetalThemeMenu(String name, MetalTheme[] themeArray) { super(name); themes = themeArray; ButtonGroup group = new ButtonGroup(); for (int i = 0; i < themes.length; i++) { JRadioButtonMenuItem item = new JRadioButtonMenuItem(themes[i]. getName()); group.add(item); add(item); item.setActionCommand(i + ""); item.addActionListener(this); if (i == 0) { item.setSelected(true); } } }
Example 4
Source File: MetalThemeMenu.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@SuppressWarnings("LeakingThisInConstructor") public MetalThemeMenu(String name, MetalTheme[] themeArray) { super(name); themes = themeArray; ButtonGroup group = new ButtonGroup(); for (int i = 0; i < themes.length; i++) { JRadioButtonMenuItem item = new JRadioButtonMenuItem(themes[i]. getName()); group.add(item); add(item); item.setActionCommand(i + ""); item.addActionListener(this); if (i == 0) { item.setSelected(true); } } }
Example 5
Source File: MetalThemeMenu.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
@SuppressWarnings("LeakingThisInConstructor") public MetalThemeMenu(String name, MetalTheme[] themeArray) { super(name); themes = themeArray; ButtonGroup group = new ButtonGroup(); for (int i = 0; i < themes.length; i++) { JRadioButtonMenuItem item = new JRadioButtonMenuItem(themes[i]. getName()); group.add(item); add(item); item.setActionCommand(i + ""); item.addActionListener(this); if (i == 0) { item.setSelected(true); } } }
Example 6
Source File: MetalThemeMenu.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@SuppressWarnings("LeakingThisInConstructor") public MetalThemeMenu(String name, MetalTheme[] themeArray) { super(name); themes = themeArray; ButtonGroup group = new ButtonGroup(); for (int i = 0; i < themes.length; i++) { JRadioButtonMenuItem item = new JRadioButtonMenuItem(themes[i]. getName()); group.add(item); add(item); item.setActionCommand(i + ""); item.addActionListener(this); if (i == 0) { item.setSelected(true); } } }
Example 7
Source File: FiltersDescriptor.java From netbeans with Apache License 2.0 | 5 votes |
protected final JRadioButtonMenuItem obtainMenuItem () { JRadioButtonMenuItem menuItem = new JRadioButtonMenuItem(); Mnemonics.setLocalizedText(menuItem, filterItem.getDisplayName()); menuItem.setAction(this); menuItem.addHierarchyListener(new ParentChangeListener(menuItem)); menuItem.setSelected(filterItem.isSelected()); return menuItem; }
Example 8
Source File: CModuleContainerNodeMenuBuilder.java From binnavi with Apache License 2.0 | 5 votes |
@Override protected void createMenu(final JComponent menu) { if (m_containerNode == null) { m_containerNode = getModuleContainerNode(CNodeExpander.findNode(getProjectTree(), m_database)); } menu.add(new JMenuItem(CActionProxy.proxy(new CImportModuleAction(getParent(), m_database)))); menu.add(new JMenuItem(CActionProxy .proxy(new CRefreshRawModulesAction(getParent(), m_database)))); menu.add(new JMenuItem(CActionProxy.proxy(new CResolveAllFunctionsAction(menu, m_database)))); menu.add(new JSeparator()); final JMenu sortMenu = new JMenu("Sort"); final JRadioButtonMenuItem idMenu = new JRadioButtonMenuItem(new CActionSortModulesById(m_containerNode)); idMenu.setSelected(!m_containerNode.isSorted()); sortMenu.add(idMenu); final JRadioButtonMenuItem nameMenu = new JRadioButtonMenuItem(new CActionSortModulesByName(m_containerNode)); nameMenu.setSelected(m_containerNode.isSorted()); sortMenu.add(nameMenu); menu.add(sortMenu); }
Example 9
Source File: ContextualMenuHelper.java From PyramidShader with GNU General Public License v3.0 | 5 votes |
public void addPopupMenu(String popupName,final EnumProperty property,final Runnable runnable) { Object[] values = property.getValues(); JMenu myPopup = new JMenu(popupName); for(int a = 0; a<values.length; a++) { final Object currentValue = values[a]; final JRadioButtonMenuItem menuItem = new JRadioButtonMenuItem(currentValue.toString()); myPopup.add(menuItem); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { property.setValue(currentValue); SwingUtilities.invokeLater(runnable); } }); property.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { SwingUtilities.invokeLater(new Runnable() { public void run() { menuItem.setSelected(currentValue.equals(property.getValue())); } }); SwingUtilities.invokeLater(runnable); } }); menuItem.setSelected(currentValue.equals(property.getValue())); } popup.add(myPopup); }
Example 10
Source File: ProfilesMenuBuilder.java From raccoon4 with Apache License 2.0 | 5 votes |
@Override public void onDataSetChange(DatasetEvent event) { if (event instanceof PlayProfileEvent) { PlayProfileEvent ppe = (PlayProfileEvent) event; if (ppe.isConnection()) { boolean a = ppe.isActivation(); edit.setEnabled(a); delete.setEnabled(a); } menu.removeAll(); PlayProfileDao dao = (PlayProfileDao) event.getSource(); List<PlayProfile> profiles = dao.list(); PlayProfile def = dao.get(); ButtonGroup bg = new ButtonGroup(); for (PlayProfile profile : profiles) { ProfileAction pa = new ProfileAction(globals, profile); JRadioButtonMenuItem item = new JRadioButtonMenuItem(pa); bg.add(item); menu.add(item); item.setSelected(def != null && def.getAlias().equals(profile.getAlias())); } menu.add(new JSeparator()); menu.add(add); menu.add(edit); menu.add(delete); } }
Example 11
Source File: VariablesSwitchViewAction.java From netbeans with Apache License 2.0 | 5 votes |
@Override public JMenuItem getPopupPresenter() { JMenu viewAsPopup = new JMenu(NbBundle.getMessage(SwitchViewAction.class, "CTL_ViewAs_Popup")); JRadioButtonMenuItem tableView = new ViewAsMenuItem(VIEW_TYPE_TABLE); JRadioButtonMenuItem treeView = new ViewAsMenuItem(VIEW_TYPE_TREE); String type = preferences.get(VIEW_TYPE, null); if (type == null || type.equals(VIEW_TYPE_TABLE)) { tableView.setSelected(true); } else { treeView.setSelected(true); } viewAsPopup.add(tableView); viewAsPopup.add(treeView); return viewAsPopup; }
Example 12
Source File: ContextualMenuHelper.java From pumpernickel with MIT License | 5 votes |
/** * * @param popupName * @param property * @param runnable * an optional runnable to invoke when the property changes. This * may be null. * @return */ public JMenu addPopupMenu(String popupName, final EnumProperty property, final Runnable runnable) { Object[] values = property.getValues(); JMenu myPopup = new JMenu(popupName); for (int a = 0; a < values.length; a++) { final Object currentValue = values[a]; final JRadioButtonMenuItem menuItem = new JRadioButtonMenuItem( currentValue.toString()); myPopup.add(menuItem); menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { property.setValue(currentValue); if (runnable != null) SwingUtilities.invokeLater(runnable); } }); property.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { SwingUtilities.invokeLater(new Runnable() { public void run() { menuItem.setSelected(currentValue.equals(property .getValue())); } }); if (runnable != null) SwingUtilities.invokeLater(runnable); } }); menuItem.setSelected(currentValue.equals(property.getValue())); } popup.add(myPopup); return myPopup; }
Example 13
Source File: SwingSet3.java From littleluck with Apache License 2.0 | 5 votes |
protected JRadioButtonMenuItem createLookAndFeelItem(String lafName, String lafClassName) { JRadioButtonMenuItem lafItem = new LuckRadioButtonMenuItem(); lafItem.setSelected(lafClassName.equals(lookAndFeel)); lafItem.setHideActionText(true); lafItem.setAction(getAction("setLookAndFeel")); lafItem.setText(lafName); lafItem.setActionCommand(lafClassName); lookAndFeelRadioGroup.add(lafItem); return lafItem; }
Example 14
Source File: WindowMenuItemManager.java From Logisim with GNU General Public License v3.0 | 4 votes |
void setSelected(boolean selected) { for (JRadioButtonMenuItem item : menuItems.values()) { item.setSelected(selected); } }
Example 15
Source File: FunctionTool.java From osp with GNU General Public License v3.0 | 4 votes |
/** * Sets the font level. * * @param level the level */ public void setFontLevel(int level) { level = Math.max(0, level); if(level==fontLevel) { return; } fontLevel = level; boolean vis = isVisible(); setVisible(false); FontSizer.setFonts(this, level); FontSizer.setFonts(contentPane, level); FontSizer.setFonts(popup, level); FontSizer.setFonts(fontButton, level); for(Iterator<FunctionPanel> it = panels.values().iterator(); it.hasNext(); ) { FunctionPanel next = it.next(); if(next==getSelectedPanel()) { continue; } next.setFontLevel(level); } if(level<popup.getSubElements().length) { MenuElement[] e = popup.getSubElements(); JRadioButtonMenuItem item = (JRadioButtonMenuItem) e[level]; item.setSelected(true); } int n = dropdown.getSelectedIndex(); Object[] items = new Object[dropdown.getItemCount()]; for (int i=0; i<items.length; i++) { items[i] = dropdown.getItemAt(i); } DefaultComboBoxModel model = new DefaultComboBoxModel(items); dropdown.setModel(model); dropdown.setSelectedItem(n); java.awt.Container c = contentPane.getTopLevelAncestor(); Dimension dim = c.getSize(); dim.width = c.getMinimumSize().width; int h = (int)(280*FontSizer.getFactor(level)); h = Math.max(h, dim.height); h = Math.min(h, (int)Toolkit.getDefaultToolkit().getScreenSize().getHeight()); dim.height = h; setSize(dim); c.setSize(dim); setVisible(vis); refreshDropdown(null); }
Example 16
Source File: NameActions.java From netbeans with Apache License 2.0 | 4 votes |
private void updateMenuItem () { final JRadioButtonMenuItem mi = obtainMenuItem(); mi.setSelected(filters.isFqn()); }
Example 17
Source File: ViewActionSupport.java From netbeans with Apache License 2.0 | 4 votes |
@Override protected void updateMenuItem () { JRadioButtonMenuItem mi = obtainMenuItem(); mi.setSelected(views.getViewMode() == ViewMode.CATEGORIZED); }
Example 18
Source File: MainFrame.java From uima-uimaj with Apache License 2.0 | 4 votes |
/** * Creates the tools menu. * * @return the j menu */ private JMenu createToolsMenu() { JMenu toolsMenu = new JMenu("Tools"); toolsMenu.setMnemonic(KeyEvent.VK_T); this.tsViewerItem = new JMenuItem("View Typesystem", KeyEvent.VK_T); this.tsViewerItem.addActionListener(new ShowTypesystemHandler(this)); this.tsViewerItem.setEnabled(false); toolsMenu.add(this.tsViewerItem); this.allAnnotationViewerItem = new JMenuItem("Show Selected Annotations", KeyEvent.VK_A); this.allAnnotationViewerItem.addActionListener(new ShowAnnotatedTextHandler(this)); toolsMenu.add(this.allAnnotationViewerItem); this.allAnnotationViewerItem.setEnabled(false); this.acdItem = new JMenuItem("Customize Annotation Display", KeyEvent.VK_C); toolsMenu.add(this.acdItem); this.acdItem.setEnabled(false); this.acdItem.addActionListener(new ShowAnnotationCustomizerHandler(this)); JMenu logConfig = new JMenu("Set Log Level"); ButtonGroup levelGroup = new ButtonGroup(); // get current log level setting String curLogLevel = LogManager.getLogManager().getProperty(".level"); // create log config menu with available log levels Iterator<Level> levelIt = MainFrame.logLevels.iterator(); while (levelIt.hasNext()) { Level level = levelIt.next(); JRadioButtonMenuItem item = new JRadioButtonMenuItem(level.toString()); // select current log level if (level.toString().equals(curLogLevel)) { item.setSelected(true); } item.addActionListener(new SetLogConfigHandler()); levelGroup.add(item); logConfig.add(item); } toolsMenu.add(logConfig); JMenuItem logViewer = new JMenuItem("View Log File", KeyEvent.VK_L); logViewer.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { LogFileViewer viewer = new LogFileViewer("Log file: " + MainFrame.this.logFile.getAbsolutePath()); viewer.addWindowListener(new CloseLogViewHandler(MainFrame.this)); Dimension dim = getDimension(logViewSizePref); if (dim == null) { dim = logFileDimensionDefault; } viewer.init(MainFrame.this.logFile, dim); } }); toolsMenu.add(logViewer); return toolsMenu; }
Example 19
Source File: SortActionSupport.java From netbeans with Apache License 2.0 | 4 votes |
protected void updateMenuItem () { JRadioButtonMenuItem mi = obtainMenuItem(); mi.setSelected(!filters.isNaturalSort()); }
Example 20
Source File: MenuBaseAction.java From constellation with Apache License 2.0 | 3 votes |
/** * create a new radio button widget * * @param label string * @param group button group * @param defaultValue value */ protected void initRadioButton(final String label, final String group, final boolean defaultValue) { putValue(Action.NAME, label); putValue(Action.SHORT_DESCRIPTION, label); menuButton = new JRadioButtonMenuItem(this); menuButton.setSelected(defaultValue); }