javax.swing.JRadioButtonMenuItem Java Examples

The following examples show how to use javax.swing.JRadioButtonMenuItem. 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: MainMenuBar.java    From Carcassonne with Eclipse Public License 2.0 6 votes vote down vote up
private void buildHandMenu() {
    JMenuItem[] itemTiles = new JRadioButtonMenuItem[GameSettings.MAXIMAL_TILES_ON_HAND];
    menuHand = new JMenu(HAND_SETTINGS);
    ButtonGroup group = new ButtonGroup();
    for (int i = 0; i < itemTiles.length; i++) {
        int numberOfTiles = i + 1;
        String itemText = numberOfTiles + TILES_PER_PLAYER;
        if (numberOfTiles == 1) {
            itemText += CLASSIC;
        }
        itemTiles[i] = new JRadioButtonMenuItem(itemText);
        itemTiles[i].addActionListener(event -> settings.setTilesPerPlayer(numberOfTiles));
        group.add(itemTiles[i]);
        menuHand.add(itemTiles[i]);
    }
    itemTiles[settings.getTilesPerPlayer() - 1].setSelected(true);
}
 
Example #2
Source File: MetalThemeMenu.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@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 #3
Source File: ButtonBuilders.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
static ComponentBuilder getBuilder(Instance instance, Heap heap) {
    if (DetailsUtils.isSubclassOf(instance, JButton.class.getName())) {
        return new JButtonBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JCheckBox.class.getName())) {
        return new JCheckBoxBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JRadioButton.class.getName())) {
        return new JRadioButtonBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JToggleButton.class.getName())) {
        return new JToggleButtonBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JCheckBoxMenuItem.class.getName())) {
        return new JCheckBoxMenuItemBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JRadioButtonMenuItem.class.getName())) {
        return new JRadioButtonMenuItemBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JMenu.class.getName())) {
        return new JMenuBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JMenuBar.class.getName())) {
        return new JMenuBarBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JMenuItem.class.getName())) {
        return new JMenuItemBuilder(instance, heap);
    }
    return null;
}
 
Example #4
Source File: MetalThemeMenu.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@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 openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@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 vote down vote up
@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: DropTargetLayer.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static int getIconLeft(JMenuItem item) {
    if(Utilities.isWindows()) {
        if(isVista()) {
            return 1;
        }
        if(hasRadioOrCheckSibling(item)) {
            return 20;
        } else {
            return 20;
        }
    }
    
    if(isAqua()) {
        if(item instanceof JRadioButtonMenuItem) {
            return 11;
        }
        return 14;
    }
    
    //metal or other (hopefully) basic derived L&Fs
    if(isRadioOrCheck(item)) {
        return 20;
    }
    return 10;
}
 
Example #8
Source File: DebuggingActionsProvider.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public JMenuItem getPopupPresenter() {
    JMenu displayAsPopup = new JMenu();
    Mnemonics.setLocalizedText(displayAsPopup, NbBundle.getMessage(DebuggingActionsProvider.class, "CTL_Session_Popup_Language"));

    String [] languages = session.getSupportedLanguages();
    String currentLanguage = session.getCurrentLanguage();
    for (int i = 0; i < languages.length; i++) {
        final String language = languages[i];
        JRadioButtonMenuItem langItem = new JRadioButtonMenuItem(new AbstractAction(language) {
            public void actionPerformed(ActionEvent e) {
                session.setCurrentLanguage(language);
            }
        });
        if (currentLanguage.equals(language)) langItem.setSelected(true);
        displayAsPopup.add(langItem);
    }
    return displayAsPopup;
}
 
Example #9
Source File: ShuffleMenuBar.java    From Shuffle-Move with GNU General Public License v3.0 6 votes vote down vote up
private JMenu makeGradingMenu() {
   JMenu menu = new JMenu(getString(KEY_GRADING_MENU));
   buttonToi18nKeyMap.put(menu, () -> getString(KEY_GRADING_MENU));
   GradingMode selectedMode = getUser().getCurrentGradingMode();
   ButtonGroup group = new ButtonGroup();
   modeMap = new HashMap<GradingMode, AbstractButton>();
   for (GradingMode mode : getUser().getGradingModeManager().getGradingModeValues()) {
      String text = mode.geti18nString();
      JRadioButtonMenuItem menuItem = new JRadioButtonMenuItem(new AbstractAction(text) {
         @Override
         public void actionPerformed(ActionEvent e) {
            getUser().setGradingMode(mode);
         }
      });
      if (mode.equals(selectedMode)) {
         menuItem.setSelected(true);
      }
      group.add(menuItem);
      menu.add(menuItem);
      modeMap.put(mode, menuItem);
      buttonToi18nKeyMap.put(menuItem, () -> mode.geti18nString());
   }
   return menu;
}
 
Example #10
Source File: SelectTrackAction.java    From tuxguitar with GNU Lesser General Public License v2.1 6 votes vote down vote up
protected void processAction(TGActionContext context) {
	final AWTEvent awtEvent = context.getAttribute(AWTEvent.class.getName());
	
	final Caret caret = TuxGuitar.instance().getTablatureEditor().getTablature().getCaret();
	final JButton button = (JButton) awtEvent.getSource();
	final JPopupMenu menu = new JPopupMenu();
	Iterator<?> it = TuxGuitar.instance().getTablatureEditor().getTablature().getSong().getTracks();
	while( it.hasNext() ){
		final TGTrack track = (TGTrack) it.next();
		JMenuItem item = new JRadioButtonMenuItem( track.getName() , (track.getNumber() == caret.getTrack().getNumber()) );
		item.setFont( TGConfig.FONT_WIDGETS );
		item.addActionListener( new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				caret.update( track.getNumber() );
				TuxGuitar.instance().updateCache( true );
			}
		});
		menu.add( item );
	}
	menu.show(button, 0, button.getHeight() );
}
 
Example #11
Source File: MetalThemeMenu.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
@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 #12
Source File: MetalThemeMenu.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
@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 #13
Source File: MetalThemeMenu.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@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 #14
Source File: MetalThemeMenu.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@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 #15
Source File: MetalThemeMenu.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@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 #16
Source File: MetalThemeMenu.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@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 #17
Source File: ButtonBuilders.java    From netbeans with Apache License 2.0 6 votes vote down vote up
static ComponentBuilder getBuilder(Instance instance, Heap heap) {
    if (DetailsUtils.isSubclassOf(instance, JButton.class.getName())) {
        return new JButtonBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JCheckBox.class.getName())) {
        return new JCheckBoxBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JRadioButton.class.getName())) {
        return new JRadioButtonBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JToggleButton.class.getName())) {
        return new JToggleButtonBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JCheckBoxMenuItem.class.getName())) {
        return new JCheckBoxMenuItemBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JRadioButtonMenuItem.class.getName())) {
        return new JRadioButtonMenuItemBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JMenu.class.getName())) {
        return new JMenuBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JMenuBar.class.getName())) {
        return new JMenuBarBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JMenuItem.class.getName())) {
        return new JMenuItemBuilder(instance, heap);
    }
    return null;
}
 
Example #18
Source File: ActionPopupButton.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected void populatePopup(JPopupMenu popup) {
    for (final Action _action : actions) {
        if (_action != null) {
            popup.add(new JRadioButtonMenuItem(_action.getValue(Action.NAME).toString(), _action == action) {
                protected void fireActionPerformed(ActionEvent e) {
                    selectAction(_action);
                    _action.actionPerformed(e);
                }
            });
        } else {
            popup.addSeparator();
        }
    }
}
 
Example #19
Source File: SetMainProject.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void checkProjectNames() {
    for(Component componentIter : subMenu.getMenuComponents()) {
        if(componentIter instanceof JRadioButtonMenuItem) {
            JRadioButtonMenuItem menuItem = (JRadioButtonMenuItem) componentIter;
            Project projectIter = getItemProject(menuItem);
            if(projectIter != null && !ProjectUtils.getInformation(projectIter).getDisplayName().equals(menuItem.getText())) {
                menuItem.setText(ProjectUtils.getInformation(projectIter).getDisplayName());
            }
        }
    }
}
 
Example #20
Source File: ViewMenu.java    From triplea with GNU General Public License v3.0 5 votes vote down vote up
private void addMapSkinsMenu() {
  final JMenu mapSubMenu = new JMenu("Map Skins");
  mapSubMenu.setMnemonic(KeyEvent.VK_K);
  add(mapSubMenu);
  final ButtonGroup mapButtonGroup = new ButtonGroup();
  final Map<String, String> skins = AbstractUiContext.getSkins(frame.getGame().getData());
  mapSubMenu.setEnabled(skins.size() > 1);
  for (final String key : skins.keySet()) {
    final JMenuItem mapMenuItem = new JRadioButtonMenuItem(key);
    mapButtonGroup.add(mapMenuItem);
    mapSubMenu.add(mapMenuItem);
    if (skins.get(key).equals(AbstractUiContext.getMapDir())) {
      mapMenuItem.setSelected(true);
    }
    mapMenuItem.addActionListener(
        e -> {
          try {
            frame.updateMap(skins.get(key));
            if (uiContext.getMapData().getHasRelief()) {
              showMapDetails.setSelected(true);
            }
            showMapDetails.setEnabled(uiContext.getMapData().getHasRelief());
          } catch (final Exception exception) {
            log.log(Level.SEVERE, "Error Changing Map Skin2", exception);
          }
        });
  }
}
 
Example #21
Source File: FiltersDescriptor.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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 #22
Source File: FileList.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
private void updateViewMenuItemsGroup() {
	Enumeration<AbstractButton> en = viewButtonGroup.getElements();
	while (en.hasMoreElements()) {
		JRadioButtonMenuItem rbm = (JRadioButtonMenuItem) en.nextElement();

		if (rbm.getActionCommand().equals(VIEW_TYPE + filechooserUI.getView())) {
			viewButtonGroup.setSelected(rbm.getModel(), true);
		}
	}
}
 
Example #23
Source File: NbMenuItem.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
     * @param it
     * @return instance of NbMenuItem constructed from parameter it */
    public NbMenuItem(JMenuItem it) {
        setName(it.getText());//getLabel();
        this.accelerator = (it.getAccelerator() == null) ? null : it.getAccelerator().toString();
        this.mnemo = (char) it.getMnemonic();
//        System.out.println("NbMenuItem ["+name+"] - mnemo: ["+it.getMnemonic()+"]"); why are the mnemonic always in capital?
        this.enabled = it.isEnabled();
        this.checkbox = it instanceof JCheckBoxMenuItem;
        this.radiobutton = it instanceof JRadioButtonMenuItem;
        this.checked = it.isSelected();
    }
 
Example #24
Source File: NbMenuItem.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
     * @param it
     * @return instance of NbMenuItem constructed from parameter it */
    public NbMenuItem(JMenuItem it) {
        setName(it.getText());//getLabel();
        this.accelerator = (it.getAccelerator() == null) ? null : it.getAccelerator().toString();
        this.mnemo = (char) it.getMnemonic();
//        System.out.println("NbMenuItem ["+name+"] - mnemo: ["+it.getMnemonic()+"]"); why are the mnemonic always in capital?
        this.enabled = it.isEnabled();
        this.checkbox = it instanceof JCheckBoxMenuItem;
        this.radiobutton = it instanceof JRadioButtonMenuItem;
        this.checked = it.isSelected();
    }
 
Example #25
Source File: ContextualMenuHelper.java    From pumpernickel with MIT License 5 votes vote down vote up
/**
 * 
 * @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 #26
Source File: JPin.java    From firmata4j with MIT License 5 votes vote down vote up
public final void setModel(final Pin model) {
    if (this.model != null) {
        this.model.removeEventListener(this);
        modesMenu.removeAll();
    }
    this.model = model;
    ButtonGroup group = new ButtonGroup();
    for (Pin.Mode mode : model.getSupportedModes()) {
        Action action = new AbstractAction(mode.name()) {
            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    model.setMode((Pin.Mode) getValue("mode"));
                } catch (IOException ex) {
                    JOptionPane.showMessageDialog(JPin.this, ex.getLocalizedMessage(), "", JOptionPane.ERROR_MESSAGE);
                }
            }
        };
        action.putValue("mode", mode);
        JMenuItem item = new JRadioButtonMenuItem(action);
        item.setSelected(model.getMode() == mode);
        group.add(item);
        modesMenu.add(item);
    }
    model.addEventListener(this);
    refreshIcon();
}
 
Example #27
Source File: FrameWithMenuShortcut.java    From JavaExercises with GNU General Public License v2.0 5 votes vote down vote up
public FrameWithMenuShortcut(String title) {
    JMenu fileMenu = new JMenu("File"); // Create File menu
    JMenu elementMenu = new JMenu("Elements"); // Create Elements menu
    fileMenu.setMnemonic('F'); // Create shortcut
    elementMenu.setMnemonic('E'); // Create shortcut
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setJMenuBar(menuBar);
    newItem = fileMenu.add("New");
    openItem = fileMenu.add("Open");
    closeItem = fileMenu.add("Close");
    fileMenu.addSeparator();
    saveItem = fileMenu.add("Save");
    saveAsItem = fileMenu.add("Save As...");
    fileMenu.addSeparator();
    printItem = fileMenu.add("Print");
    elementMenu.add(lineItem = new JRadioButtonMenuItem("Line", true));
    elementMenu.add(rectangleItem = new JRadioButtonMenuItem("Rectangle", false));
    elementMenu.add(circleItem = new JRadioButtonMenuItem("Circle", false));
    ButtonGroup types = new ButtonGroup();
    types.add(lineItem);
    types.add(rectangleItem);
    types.add(circleItem);
    elementMenu.addSeparator();
    elementMenu.add(redItem = new JCheckBoxMenuItem("Red", false));
    elementMenu.add(yellowItem = new JCheckBoxMenuItem("Yellow", false));
    menuBar.add(fileMenu);
    menuBar.add(elementMenu);
    newItem.setAccelerator(KeyStroke.getKeyStroke('N', CTRL_DOWN_MASK));
    openItem.setAccelerator(KeyStroke.getKeyStroke('O', CTRL_DOWN_MASK));
    saveItem.setAccelerator(KeyStroke.getKeyStroke('S', CTRL_DOWN_MASK));
    printItem.setAccelerator(KeyStroke.getKeyStroke('P', CTRL_DOWN_MASK));
    lineItem.setAccelerator(KeyStroke.getKeyStroke('L', CTRL_DOWN_MASK));
    rectangleItem.setAccelerator(KeyStroke.getKeyStroke('E', CTRL_DOWN_MASK));
    circleItem.setAccelerator(KeyStroke.getKeyStroke('I', CTRL_DOWN_MASK));
    elementMenu.addSeparator();
    redItem.setAccelerator(KeyStroke.getKeyStroke('R', CTRL_DOWN_MASK));
    yellowItem.setAccelerator(KeyStroke.getKeyStroke('Y', CTRL_DOWN_MASK));
    menuBar.add(fileMenu);
    menuBar.add(elementMenu);
}
 
Example #28
Source File: WindowMenuItemManager.java    From Logisim with GNU General Public License v3.0 5 votes vote down vote up
private void removeFromManager() {
	if (!persistent && inManager) {
		inManager = false;
		for (WindowMenu menu : WindowMenuManager.getMenus()) {
			JRadioButtonMenuItem menuItem = menuItems.get(menu);
			menu.removeMenuItem(this, menuItem);
		}
		WindowMenuManager.removeManager(this);
	}
}
 
Example #29
Source File: ContextualMenuHelper.java    From PyramidShader with GNU General Public License v3.0 5 votes vote down vote up
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 #30
Source File: MaterialRadioButtonMenuItemUI.java    From material-ui-swing with MIT License 5 votes vote down vote up
@Override
protected void paintMenuItem (Graphics g, JComponent c, Icon checkIcon, Icon arrowIcon, Color background, Color foreground, int defaultTextIconGap) {
	JRadioButtonMenuItem j = (JRadioButtonMenuItem) c;
	if (j.isSelected ()) {
		super.paintMenuItem (MaterialDrawingUtils.getAliasedGraphics (g), c, UIManager.getIcon ("RadioButtonMenuItem.selectedCheckIcon"), arrowIcon, background, foreground, defaultTextIconGap);
		return;
	}
	super.paintMenuItem (MaterialDrawingUtils.getAliasedGraphics (g), c, UIManager.getIcon ("RadioButtonMenuItem.checkIcon"), arrowIcon, background, foreground, defaultTextIconGap);
}