001package jmri.jmrit.operations.routes.tools; 002 003import java.awt.Frame; 004import java.awt.event.ActionEvent; 005 006import javax.swing.AbstractAction; 007 008import jmri.jmrit.operations.routes.Route; 009 010/** 011 * Swing action to create and register a SetTrainIconRouteFrame object. 012 * 013 * @author Bob Jacobsen Copyright (C) 2001 014 * @author Daniel Boudreau Copyright (C) 2010 015 */ 016public class SetTrainIconRouteAction extends AbstractAction { 017 018 Route _route; 019 020 public SetTrainIconRouteAction(Route route) { 021 super(Bundle.getMessage("MenuSetTrainIconRoute")); 022 _route = route; 023 setEnabled(route != null); 024 } 025 026 SetTrainIconRouteFrame f = null; 027 028 @Override 029 public void actionPerformed(ActionEvent e) { 030 if (f == null || !f.isVisible()) { 031 f = new SetTrainIconRouteFrame(_route); 032 } 033 f.setExtendedState(Frame.NORMAL); 034 f.setVisible(true); // this also brings the frame into focus 035 } 036}