001package jmri.jmrit.display.panelEditor; 002 003import java.awt.event.ActionEvent; 004 005import javax.swing.AbstractAction; 006 007import jmri.InstanceManager; 008import jmri.jmrit.display.EditorManager; 009import jmri.util.JmriJFrame; 010 011/** 012 * Start a PanelEditor. 013 * 014 * @author Bob Jacobsen Copyright (C) 2002 015 * @see jmri.jmrit.display.panelEditor.PanelEditorAction 016 */ 017public class PanelEditorAction extends AbstractAction { 018 019 public PanelEditorAction(String s) { 020 super(s); 021 } 022 023 public PanelEditorAction() { 024 this("New Panel"); 025 } // NOI18N 026 027 @Override 028 public void actionPerformed(ActionEvent e) { 029 String name = Bundle.getMessage("PanelDefaultName", "").trim(); // "Panel" 030 for (int i = 2; i < 100; i++) { 031 if (JmriJFrame.getFrame(name) != null) { 032 name = Bundle.getMessage("PanelDefaultName", i); 033 } 034 } 035 PanelEditor frame = new PanelEditor(name); 036 frame.setKeepSize(false); 037 InstanceManager.getDefault(EditorManager.class).add(frame); 038 frame.setLocation(20, 20); 039 040 frame.setTitle(); 041 042 frame.pack(); 043 frame.setVisible(true); 044 frame.newPanelDefaults(); 045 } 046}