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);
}
use of javax.swing.JRadioButtonMenuItem in project JMRI by JMRI.
the class ControlPanelEditor method makeSelectTypeButton.
private JRadioButtonMenuItem makeSelectTypeButton(String label, String className) {
JRadioButtonMenuItem button = new JRadioButtonMenuItem(Bundle.getMessage(label));
button.addActionListener(new ActionListener() {
String cName;
ActionListener init(String name) {
cName = name;
return this;
}
@Override
public void actionPerformed(ActionEvent event) {
selectType(cName);
}
}.init(className));
return button;
}
use of javax.swing.JRadioButtonMenuItem in project JMRI by JMRI.
the class PanelEditor method addColorMenuEntry.
protected void addColorMenuEntry(JMenu menu, ButtonGroup colorButtonGroup, final String name, Color color) {
ActionListener a = new ActionListener() {
//final String desiredName = name;
Color desiredColor;
@Override
public void actionPerformed(ActionEvent e) {
if (desiredColor != null) {
setBackgroundColor(desiredColor);
} else {
clearBackgroundColor();
}
}
ActionListener init(Color c) {
desiredColor = c;
return this;
}
}.init(color);
JRadioButtonMenuItem r = new JRadioButtonMenuItem(name);
r.addActionListener(a);
if (color == null) {
color = defaultBackgroundColor;
}
setColorButton(getBackgroundColor(), color, r);
colorButtonGroup.add(r);
menu.add(r);
}
use of javax.swing.JRadioButtonMenuItem in project JMRI by JMRI.
the class AnalogClock2Display method addRateMenuEntry.
@SuppressFBWarnings(value = "FE_FLOATING_POINT_EQUALITY", justification = "fixed number of possible values")
void addRateMenuEntry(JMenu menu, final int newrate) {
JRadioButtonMenuItem button = new JRadioButtonMenuItem("" + newrate + ":1");
button.addActionListener(new ActionListener() {
final int r = newrate;
@Override
public void actionPerformed(ActionEvent e) {
try {
clock.userSetRate(r);
rate = r;
} catch (TimebaseRateException t) {
log.error("TimebaseRateException for rate= " + r + ". " + t);
}
}
});
rateButtonGroup.add(button);
// next line is the FE_FLOATING_POINT_EQUALITY annotated above
if (rate == newrate) {
button.setSelected(true);
} else {
button.setSelected(false);
}
menu.add(button);
}
Aggregations