001package apps.gui3;
002
003import java.awt.Dimension;
004import java.awt.Rectangle;
005import java.awt.Toolkit;
006import java.awt.event.ActionEvent;
007import javax.swing.Icon;
008import javax.swing.JFrame;
009import javax.swing.SwingUtilities;
010import jmri.util.swing.JmriPanel;
011import jmri.util.swing.WindowInterface;
012
013public class FirstTimeStartUpWizardAction extends jmri.util.swing.JmriAbstractAction {
014
015    public FirstTimeStartUpWizardAction(String s, WindowInterface wi) {
016        super(s, wi);
017    }
018
019    public FirstTimeStartUpWizardAction(String s, Icon i, WindowInterface wi) {
020        super(s, i, wi);
021    }
022
023    public FirstTimeStartUpWizardAction(String s) {
024        super(s);
025    }
026
027    // never invoked, because we overrode actionPerformed above
028    @Override
029    public JmriPanel makePanel() {
030        throw new IllegalArgumentException("Should not be invoked");
031    }
032
033    static jmri.util.JmriJFrame f;
034
035    apps.gui3.Apps3 app;
036
037    public void setApp(apps.gui3.Apps3 app) {
038        this.app = app;
039    }
040
041    public void actionPerformed() {
042        // create the frame
043        if (f == null) {
044            f = new jmri.util.JmriJFrame("DecoderPro Wizard", false, false);
045            // Update the GUI Look and Feel
046            // This is needed as certain controls are instantiated
047            // prior to the setup of the Look and Feel
048            SwingUtilities.updateComponentTreeUI(f);
049        }
050        FirstTimeStartUpWizard wiz = new FirstTimeStartUpWizard(f, app);
051        f.setPreferredSize(new java.awt.Dimension(700, 400));
052        f.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
053        f.add(wiz.getPanel());
054        f.pack();
055
056        Dimension screenDim
057                = Toolkit.getDefaultToolkit().getScreenSize();
058        Rectangle winDim = f.getBounds();
059        winDim.height = winDim.height + 10;
060        winDim.width = winDim.width + 10;
061        f.setLocation((screenDim.width - winDim.width) / 2,
062                (screenDim.height - winDim.height) / 2);
063        f.setSize(winDim.width, winDim.height);
064
065        f.setVisible(true);
066    }
067
068    @Override
069    public void actionPerformed(ActionEvent e) {
070        actionPerformed();
071    }
072
073}