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