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.TrainsTableFrame; 009 010/** 011 * Swing action to create and register a TrainsScriptFrame. 012 * 013 * @author Bob Jacobsen Copyright (C) 2001 014 * @author Daniel Boudreau Copyright (C) 2011 015 */ 016public class TrainsScriptAction extends AbstractAction { 017 018 public TrainsScriptAction(TrainsTableFrame frame) { 019 super(Bundle.getMessage("MenuItemScripts")); 020 _frame = frame; 021 } 022 023 TrainsTableFrame _frame; // the parent frame that is launching the TrainScriptFrame. 024 025 TrainsScriptFrame 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 TrainsScriptFrame(); 034 f.setLocation(_frame.getLocation()); 035 f.initComponents(); 036 f.setExtendedState(Frame.NORMAL); 037 f.setTitle(Bundle.getMessage("MenuItemScripts")); 038 } 039} 040 041