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.Train; 009 010/** 011 * Swing action to create and register a TrainSetColorFrame object. 012 * 013 * @author Bob Jacobsen Copyright (C) 2001 014 * @author Daniel Boudreau Copyright (C) 2014 015 */ 016public class TrainsTableSetColorAction extends AbstractAction { 017 018 public TrainsTableSetColorAction() { 019 super(Bundle.getMessage("MenuItemSetTrainColor")); 020 } 021 022 Train _train = null; 023 024 public TrainsTableSetColorAction(Train train) { 025 this(); 026 _train = train; 027 } 028 029 TrainsTableSetColorFrame f = null; 030 031 @Override 032 public void actionPerformed(ActionEvent e) { 033 if (f == null || !f.isVisible()) { 034 f = new TrainsTableSetColorFrame(_train); 035 } 036 f.setExtendedState(Frame.NORMAL); 037 f.setVisible(true); // this also brings the frame into focus 038 } 039} 040 041