001package jmri.jmrit.operations.trains;
002
003import java.awt.Frame;
004import java.awt.event.ActionEvent;
005
006import javax.swing.AbstractAction;
007
008import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
009
010/**
011 * Swing action to create and register a TrainTableFrame object.
012 *
013 * @author Bob Jacobsen Copyright (C) 2001
014 * @author Daniel Boudreau Copyright (C) 2008
015 */
016public class TrainsTableAction extends AbstractAction {
017
018    public TrainsTableAction() {
019        super(Bundle.getMessage("MenuTrains")); // NOI18N
020    }
021
022    static TrainsTableFrame trainsTableFrame = null;
023
024    @Override
025    @SuppressFBWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD", justification = "Show only one TrainsTableFrame")
026    public void actionPerformed(ActionEvent e) {
027        // create a train table frame
028        if (trainsTableFrame == null || !trainsTableFrame.isVisible()) {
029            trainsTableFrame = new TrainsTableFrame();
030        }
031        trainsTableFrame.setExtendedState(Frame.NORMAL);
032        trainsTableFrame.setVisible(true); // this also brings the frame into focus
033    }
034}
035
036