1 package org.wcb.autohome;
2 /***
3 * Copyright (C) 1999 Walter Bogaardt
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18 *
19 * Project: Home Automation Interface
20 * Filename: $Id: AliceFrame.java,v 1.15 2004/07/22 03:17:53 wbogaardt Exp $
21 *
22 * $Log: AliceFrame.java,v $
23 * Revision 1.15 2004/07/22 03:17:53 wbogaardt
24 * removed deprecated methods
25 *
26 * Revision 1.14 2004/02/25 21:38:32 wbogaardt
27 * added javadocs and fixed formating for checkstyle report
28 *
29 * Revision 1.13 2004/02/23 20:23:52 wbogaardt
30 * updated version information
31 *
32 * Revision 1.12 2004/01/21 00:11:26 wbogaardt
33 * updated versions and api information
34 *
35 * Revision 1.11 2003/12/31 20:11:24 wbogaardt
36 * moved email settings to HASConfig.ini file instead. Fixed Reset button problem.
37 *
38 * Revision 1.10 2003/12/31 01:09:37 wbogaardt
39 * removed dead string reference to jhome.prop
40 *
41 * Revision 1.9 2003/12/31 00:08:08 wbogaardt
42 * fixed bug with setting look and feel and having it persist for user next time open
43 *
44 * Revision 1.8 2003/12/30 01:12:12 wbogaardt
45 * upgrade version to suggest support for internationalization
46 *
47 * Revision 1.7 2003/12/19 20:51:38 wbogaardt
48 * internationalization
49 *
50 * Revision 1.6 2003/12/12 01:34:28 wbogaardt
51 * fixed message interface was throwing stack overflow. Fixed display bug with Serial panel.
52 *
53 * Revision 1.5 2003/12/09 21:36:52 wbogaardt
54 * modified Session objects so that works with gui app as well as web app. Extended functionality of serial page in
55 * web app, and improved error traping of exceptions
56 *
57 * Revision 1.4 2003/10/06 22:44:19 wbogaardt
58 * added looks good to swing ui
59 *
60 */
61 import javax.swing.*;
62 import java.awt.BorderLayout;
63 import java.awt.Dimension;
64 import java.awt.Toolkit;
65 import java.awt.event.WindowListener;
66 import java.awt.event.WindowAdapter;
67 import java.awt.event.WindowEvent;
68 import org.wcb.common.UIDefaultsLoader;
69 import org.wcb.common.SplashScreen;
70
71 /***
72 * Creates the main frame and splash screen for the alice swing
73 * application.
74 */
75 public class AliceFrame {
76
77 private HomeCenterPanel centerPanel;
78
79 /***
80 * This provides a frame wrapper for the HomeCenterPanel class
81 * Based on the command line arguments sent from the user
82 * a splash screen will appear.
83 * @param arg arguments to be passed to either show the splash screen or not
84 */
85 public AliceFrame(String arg) {
86 UIDefaultsLoader uidef = new UIDefaultsLoader();
87 ImageIcon splashImg = new ImageIcon(Toolkit.getDefaultToolkit().createImage(AliceFrame.class.getResource("/images/X10-intro.jpg")));
88 uidef.initiateLF();
89 AutoHomeAdminSession.getInstance().initiateGUI();
90 JFrame mainFrame = new JFrame("A.L.I.C.E.");
91 centerPanel = new HomeCenterPanel();
92 WindowListener wl = new WindowAdapter() {
93 public void windowClosing(WindowEvent we) {
94 centerPanel.shutdownSystem();
95 }
96 };
97 mainFrame.addWindowListener(wl);
98 mainFrame.setSize(667, 590);
99 mainFrame.getContentPane().setLayout(new BorderLayout());
100 mainFrame.getContentPane().add(BorderLayout.NORTH, centerPanel.getToolBar());
101 mainFrame.getContentPane().add(BorderLayout.CENTER, centerPanel);
102 mainFrame.setJMenuBar(centerPanel.getJMenuBar());
103 if (!arg.startsWith("nosplash"))
104 {
105 SplashScreen splash = new SplashScreen(splashImg);
106 try
107 {
108 splash.showStatus("ALICE Ver 1.3.1a");
109 Thread.sleep(1000);
110 splash.showStatus("created by");
111 Thread.sleep(500);
112 splash.showStatus("Walter Bogaardt");
113 Thread.sleep(1000);
114 splash.showStatus("CM11A Comm API");
115 Thread.sleep(500);
116 splash.showStatus("By Jesse Peterson");
117 Thread.sleep(500);
118 Thread.sleep(500);
119 splash.close();
120 mainFrame.setVisible(true);
121 centerPanel.setTitleBar();
122 }
123 catch (Exception err)
124 {
125 err.printStackTrace();
126 }
127 }
128 else
129 {
130 mainFrame.setVisible(true);
131 centerPanel.setTitleBar();
132 }
133 Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
134 int x = (dim.width - (mainFrame.getSize().width)) / 2;
135 int y = (dim.height - (mainFrame.getSize().height)) / 2;
136 mainFrame.setBounds(x, y, mainFrame.getSize().width, mainFrame.getSize().height);
137 }
138
139 }
140
141
142