use of javax.swing.JRadioButtonMenuItem in project jgnash by ccavanaugh.
the class ThemeManager method buildLookAndFeelMenu.
/**
* Loads the menu with the available look and feels for the application
*
* @return l and f menu
*/
JMenu buildLookAndFeelMenu() {
String activeLookAndFeelName = UIManager.getLookAndFeel().getName();
// ButtonGroup buttonGroup = new ButtonGroup();
JMenu lfMenu = new JMenu();
lfMenu.setText(rb.getString("Menu.LookAndFeel.Name"));
lfMenu.add(buildSubstanceMenu());
List<String> lookAndFeels = new ArrayList<>();
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
if (isLookAndFeelAvailable(info.getClassName())) {
lookAndFeels.add(info.getClassName());
}
}
for (String lookAndFeel : KNOWN) {
if (isLookAndFeelAvailable(lookAndFeel)) {
lookAndFeels.add(lookAndFeel);
}
}
Collections.sort(lookAndFeels);
for (String lookAndFeel : lookAndFeels) {
try {
Class<?> lnfClass = Class.forName(lookAndFeel);
LookAndFeel newLAF = (LookAndFeel) lnfClass.newInstance();
JRadioButtonMenuItem button = new JRadioButtonMenuItem();
button.setText(newLAF.getName());
button.setActionCommand(lookAndFeel);
button.setName(newLAF.getName());
button.addActionListener(e -> {
Preferences pref = Preferences.userNodeForPackage(ThemeManager.class);
pref.put(LF, e.getActionCommand());
restartUI();
});
lfButtonGroup.add(button);
lfMenu.add(button);
if (newLAF.getName().equals(activeLookAndFeelName)) {
button.setSelected(true);
}
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
Logger.getLogger(ThemeManager.class.getName()).log(Level.WARNING, null, e);
}
}
return lfMenu;
}
use of javax.swing.JRadioButtonMenuItem in project jgnash by ccavanaugh.
the class ActionParser method createMenuItem.
private JMenuItem createMenuItem(final ActionNode node) {
JMenuItem menu;
Action a = actionMap.get(node.idref);
if (node.size() > 0) {
menu = new JMenu(a);
for (int i = 0; i < node.size(); i++) {
ActionNode n = node.getChildAt(i);
if (n.id == null && n.idref == null) {
// detect a separator
((JMenu) menu).addSeparator();
} else {
JMenuItem item = createMenuItem(n);
menu.add(item);
}
}
} else {
if (node.type == null || node.type.isEmpty()) {
menu = new JMenuItem(a);
} else {
switch(node.type) {
case "single":
menu = new JCheckBoxMenuItem(a);
break;
case "toggle":
menu = new JRadioButtonMenuItem(a);
if (node.group != null) {
// create a group
ButtonGroup bGroup;
if (buttonGroups.get(node.group) != null) {
bGroup = buttonGroups.get(node.group);
} else {
bGroup = new ButtonGroup();
buttonGroups.put(node.group, bGroup);
}
bGroup.add(menu);
}
break;
default:
menu = new JMenuItem(a);
break;
}
}
}
menuItemMap.put(node.idref, menu);
// store the idref in the JMenuItem
menu.putClientProperty(ID_REF_ATTRIBUTE, node.idref);
return menu;
}
use of javax.swing.JRadioButtonMenuItem in project jabref by JabRef.
the class OpenOfficePanel method showSettingsPopup.
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 libraries"));
final JMenuItem clearConnectionSettings = new JMenuItem(Localization.lang("Clear connection settings"));
ButtonGroup bg = new ButtonGroup();
bg.add(useActiveBase);
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());
}
use of javax.swing.JRadioButtonMenuItem in project JMRI by JMRI.
the class JMenuUtil method createMenuGroupFromElement.
@Nonnull
static JMenu createMenuGroupFromElement(@CheckForNull Element main, WindowInterface wi, Object context) {
String name = "<none>";
if (main == null) {
log.warn("Menu from element called without an element");
return new JMenu(name);
}
name = LocaleSelector.getAttribute(main, "name");
//Next statement left in if the xml file hasn't been converted
if ((name == null) || (name.equals(""))) {
if (main.getChild("name") != null) {
name = main.getChild("name").getText();
}
}
JMenu menu = new JMenu(name);
ButtonGroup group = new ButtonGroup();
for (Object item : main.getChildren("node")) {
Element elem = (Element) item;
Action act = actionFromNode(elem, wi, context);
JRadioButtonMenuItem menuItem = new JRadioButtonMenuItem(act);
group.add(menuItem);
menu.add(menuItem);
if (elem.getChild("current") != null) {
setMenuItemInterAction(context, elem.getChild("current").getText(), menuItem);
}
}
return menu;
}
use of javax.swing.JRadioButtonMenuItem in project JMRI by JMRI.
the class PositionablePopupUtil method addFontMenuEntry.
void addFontMenuEntry(JMenu menu, ButtonGroup fontButtonGroup, final int size) {
JRadioButtonMenuItem r = new JRadioButtonMenuItem("" + size);
r.addActionListener((ActionEvent e) -> {
setFontSize(size);
});
fontButtonGroup.add(r);
if (_textComponent.getFont().getSize() == size) {
r.setSelected(true);
} else {
r.setSelected(false);
}
menu.add(r);
}
Aggregations