001package jmri.jmrit.operations.trains.tools;
002
003import java.awt.Frame;
004import java.awt.event.ActionEvent;
005
006import javax.swing.AbstractAction;
007
008import jmri.jmrit.operations.trains.TrainEditFrame;
009
010/**
011 * Swing action to create and register a TrainScriptFrame.
012 *
013 * @author Bob Jacobsen Copyright (C) 2001
014 * @author Daniel Boudreau Copyright (C) 2010
015 */
016public class TrainScriptAction extends AbstractAction {
017
018    public TrainScriptAction(TrainEditFrame frame) {
019        super(Bundle.getMessage("MenuItemScripts"));
020        _frame = frame;
021    }
022
023    TrainEditFrame _frame; // the parent frame that is launching the TrainScriptFrame.
024
025    TrainScriptFrame f = null;
026
027    @Override
028    public void actionPerformed(ActionEvent e) {
029        // create a train scripts frame
030        if (f != null && f.isVisible()) {
031            f.dispose();
032        }
033        f = new TrainScriptFrame();
034        f.setLocation(_frame.getLocation());
035        f.initComponents(_frame);
036        f.setExtendedState(Frame.NORMAL);
037    }
038}
039
040