001package jmri.jmrit.speedometer;
002
003import java.awt.event.ActionEvent;
004import javax.swing.Icon;
005import jmri.util.swing.JmriAbstractAction;
006import jmri.util.swing.WindowInterface;
007
008/**
009 * Swing action to create and register a SpeedometerFrame
010 *
011 * @author Bob Jacobsen Copyright (C) 2001
012 */
013public class SpeedometerAction extends JmriAbstractAction {
014
015    public SpeedometerAction(String s, WindowInterface wi) {
016        super(s, wi);
017    }
018
019    public SpeedometerAction(String s, Icon i, WindowInterface wi) {
020        super(s, i, wi);
021    }
022
023    public SpeedometerAction(String s) {
024        super(s);
025
026        // disable ourself if there is no primary sensor manager available
027        if (jmri.InstanceManager.getNullableDefault(jmri.SensorManager.class) == null) {
028            setEnabled(false);
029        }
030    }
031
032    public SpeedometerAction() {
033        this("Speedometer");
034    }
035
036    @Override
037    public void actionPerformed(ActionEvent e) {
038
039        // create a SimpleProgFrame
040        SpeedometerFrame f = new SpeedometerFrame();
041        f.setVisible(true);
042
043    }
044
045    // never invoked, because we overrode actionPerformed above
046    @Override
047    public jmri.util.swing.JmriPanel makePanel() {
048        throw new IllegalArgumentException("Should not be invoked");
049    }
050}