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);
}
use of javax.swing.JRadioButtonMenuItem in project JMRI by JMRI.
the class ControlPanelEditor method makeSelectLevelMenu.
private JMenu makeSelectLevelMenu() {
JMenu menu = new JMenu(Bundle.getMessage("SelectLevel"));
ButtonGroup levelGroup = new ButtonGroup();
JRadioButtonMenuItem button = null;
for (int i = 0; i < 11; i++) {
button = new JRadioButtonMenuItem(Bundle.getMessage("selectLevel", "" + i));
levelGroup.add(button);
menu.add(button);
button.addActionListener(new ActionListener() {
int j;
ActionListener init(int k) {
j = k;
return this;
}
@Override
public void actionPerformed(ActionEvent event) {
selectLevel(j);
}
}.init(i));
}
return menu;
}
use of javax.swing.JRadioButtonMenuItem in project JMRI by JMRI.
the class LogixTableAction method setMenuBar.
/**
* Insert 2 table specific menus.
* <p>
* Accounts for the Window and Help menus, which are already added to the menu bar
* as part of the creation of the JFrame, by adding the new menus 2 places earlier
* unless the table is part of the ListedTableFrame, which adds the Help menu later on.
* @param f the JFrame of this table
*/
@Override
public void setMenuBar(BeanTableFrame f) {
loadSelectionMode();
JMenu menu = new JMenu(Bundle.getMessage("MenuOptions"));
menu.setMnemonic(KeyEvent.VK_O);
javax.swing.JMenuBar menuBar = f.getJMenuBar();
// count the number of menus to insert the TableMenus before 'Window' and 'Help'
int pos = menuBar.getMenuCount() - 1;
int offset = 1;
log.debug("setMenuBar number of menu items = " + pos);
for (int i = 0; i <= pos; i++) {
if (menuBar.getComponent(i) instanceof JMenu) {
if (((JMenu) menuBar.getComponent(i)).getText().equals(Bundle.getMessage("MenuHelp"))) {
// correct for use as part of ListedTableAction where the Help Menu is not yet present
offset = -1;
}
}
}
ButtonGroup enableButtonGroup = new ButtonGroup();
JRadioButtonMenuItem r = new JRadioButtonMenuItem(rbx.getString("EnableAll"));
r.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
enableAll(true);
}
});
enableButtonGroup.add(r);
r.setSelected(true);
menu.add(r);
r = new JRadioButtonMenuItem(rbx.getString("DisableAll"));
r.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
enableAll(false);
}
});
enableButtonGroup.add(r);
menu.add(r);
menu.addSeparator();
ButtonGroup modeButtonGroup = new ButtonGroup();
r = new JRadioButtonMenuItem(rbx.getString("UseMultiPick"));
r.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
setSelectionMode(SelectionMode.USEMULTI);
}
});
modeButtonGroup.add(r);
menu.add(r);
r.setSelected(_selectionMode == SelectionMode.USEMULTI);
r = new JRadioButtonMenuItem(rbx.getString("UseSinglePick"));
r.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
setSelectionMode(SelectionMode.USESINGLE);
}
});
modeButtonGroup.add(r);
menu.add(r);
r.setSelected(_selectionMode == SelectionMode.USESINGLE);
r = new JRadioButtonMenuItem(rbx.getString("UseComboNameBoxes"));
r.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
setSelectionMode(SelectionMode.USECOMBO);
}
});
modeButtonGroup.add(r);
menu.add(r);
r.setSelected(_selectionMode == SelectionMode.USECOMBO);
menuBar.add(menu, pos + offset);
menu = new JMenu(Bundle.getMessage("MenuTools"));
menu.setMnemonic(KeyEvent.VK_T);
JMenuItem item = new JMenuItem(rbx.getString("OpenPickListTables"));
item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
OpenPickListTable();
}
});
menu.add(item);
item = new JMenuItem(rbx.getString("FindOrphans"));
item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
findOrphansPressed(e);
}
});
menu.add(item);
item = new JMenuItem(rbx.getString("EmptyConditionals"));
item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
findEmptyPressed(e);
}
});
menu.add(item);
item = new JMenuItem(rbx.getString("CrossReference"));
item.addActionListener(new ActionListener() {
BeanTableFrame parent;
@Override
public void actionPerformed(ActionEvent e) {
new RefDialog(parent);
}
ActionListener init(BeanTableFrame f) {
parent = f;
return this;
}
}.init(f));
menu.add(item);
item = new JMenuItem(rbx.getString("DisplayWhereUsed"));
item.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
makeWhereUsedWindow();
}
});
menu.add(item);
// add this menu to the right of the previous
menuBar.add(menu, pos + offset + 1);
}
Aggregations