use of jmri.TimebaseRateException 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