001package apps; 002 003import apps.gui3.Apps3; 004import jmri.util.startup.AbstractActionModel; 005import javax.swing.Action; 006import javax.swing.JButton; 007import jmri.JmriException; 008 009/** 010 * Creates a button when the program is started. 011 * <p> 012 * The list of actions available is defined in the {@link AbstractActionModel} 013 * superclass. 014 * <p> 015 * This is a separate class, even though it has no additional behavior, so that 016 * persistence systems realize the type of data being stored. 017 * <p> 018 * This class remains in the {@code apps} package for historical reasons related 019 * to preferences storage. 020 * 021 * @author Bob Jacobsen Copyright 2003 022 * @see apps.startup.CreateButtonModelFactory 023 */ 024public class CreateButtonModel extends AbstractActionModel { 025 026 // private final static Logger log = LoggerFactory.getLogger(CreateButtonModel.class); 027 028 public CreateButtonModel() { 029 super(); 030 } 031 032 @Override 033 protected void performAction(Action action) throws JmriException { 034 JButton b = new JButton(action); 035 b.setToolTipText(this.toString()); 036 if (Apps.buttonSpace() != null) { 037 Apps.buttonSpace().add(b); 038 } else if (Apps3.buttonSpace() != null) { 039 Apps3.buttonSpace().add(b); 040 } 041 } 042}