Source code: com/virtuosotechnologies/asaph/launch/SplashScreen.java
1 /*
2 ================================================================================
3
4 FILE: SplashScreen.java
5
6 PROJECT:
7
8 Asaph
9
10 CONTENTS:
11
12 Splash screen
13
14 PROGRAMMERS:
15
16 Daniel Azuma (DA) <dazuma@kagi.com>
17
18 COPYRIGHT:
19
20 Copyright (C) 2003 Daniel Azuma (dazuma@kagi.com)
21
22 This program is free software; you can redistribute it and/or
23 modify it under the terms of the GNU General Public License as
24 published by the Free Software Foundation; either version 2
25 of the License, or (at your option) any later version.
26
27 This program is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 GNU General Public License for more details.
31
32 You should have received a copy of the GNU General Public
33 License along with this program; if not, write to
34 Free Software Foundation, Inc.
35 59 Temple Place, Suite 330
36 Boston, MA 02111-1307 USA
37
38 ================================================================================
39 */
40
41
42 package com.virtuosotechnologies.asaph.launch;
43
44
45 import java.lang.reflect.InvocationTargetException;
46 import java.awt.Font;
47 import java.awt.Color;
48 import java.awt.BorderLayout;
49 import java.awt.GridBagLayout;
50 import java.awt.GridBagConstraints;
51 import java.awt.Insets;
52 import java.awt.Dimension;
53 import java.awt.Toolkit;
54 import javax.swing.JFrame;
55 import javax.swing.JLabel;
56 import javax.swing.JPanel;
57 import javax.swing.JSeparator;
58 import javax.swing.WindowConstants;
59 import javax.swing.BorderFactory;
60 import javax.swing.SwingUtilities;
61
62
63 /**
64 * Splash screen
65 */
66 /*package*/ class SplashScreen
67 {
68 private static final Font STANDARD_FONT = new Font("Dialog", Font.PLAIN, 10);
69 private static final Color STANDARD_COLOR = Color.black;
70
71 private JFrame frame_;
72 private JLabel statusLabel_;
73
74
75 /**
76 * Constructor
77 */
78 /*package*/ SplashScreen()
79 {
80 frame_ = new JFrame();
81 frame_.setUndecorated(true);
82 frame_.setResizable(false);
83 frame_.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
84
85 JPanel mainPanel = new JPanel(new BorderLayout());
86 mainPanel.setBorder(BorderFactory.createLineBorder(Color.black));
87 frame_.setContentPane(mainPanel);
88
89 JPanel titlePanel = new JPanel(new BorderLayout());
90 TitlePane titlePane = new TitlePane(true);
91 titlePanel.add(titlePane, BorderLayout.CENTER);
92 JSeparator separator = new JSeparator();
93 titlePanel.add(separator, BorderLayout.SOUTH);
94 mainPanel.add(titlePanel, BorderLayout.CENTER);
95
96 JPanel statusPanel = new JPanel(new GridBagLayout());
97 GridBagConstraints gbc = new GridBagConstraints();
98 gbc.gridx = 0;
99 gbc.anchor = GridBagConstraints.WEST;
100 gbc.fill = GridBagConstraints.NONE;
101 gbc.weightx = 1;
102 gbc.weighty = 1;
103 gbc.insets = new Insets(3, 5, 1, 5);
104 JLabel label = new JLabel(ResourceAccess.Strings.buildString("VersionText"));
105 label.setFont(STANDARD_FONT);
106 label.setForeground(STANDARD_COLOR);
107 statusPanel.add(label, gbc);
108 gbc.insets = new Insets(1, 5, 5, 5);
109 statusLabel_ = new JLabel(ResourceAccess.Strings.buildString("Splash_InitializeStatus"));
110 statusLabel_.setFont(STANDARD_FONT);
111 statusLabel_.setForeground(STANDARD_COLOR);
112 statusPanel.add(statusLabel_, gbc);
113 mainPanel.add(statusPanel, BorderLayout.SOUTH);
114
115 frame_.pack();
116 Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
117 frame_.setLocation((screenSize.width-frame_.getWidth())/2,
118 (screenSize.height-frame_.getHeight())/2);
119
120 try
121 {
122 SwingUtilities.invokeAndWait(
123 new Runnable()
124 {
125 public void run()
126 {
127 frame_.setVisible(true);
128 }
129 });
130 }
131 catch (InterruptedException ex)
132 {
133 }
134 catch (InvocationTargetException ex)
135 {
136 }
137 }
138
139
140 /*package*/ void setStatusString(
141 final String str)
142 {
143 try
144 {
145 SwingUtilities.invokeAndWait(
146 new Runnable()
147 {
148 public void run()
149 {
150 statusLabel_.setText(str);
151 }
152 });
153 }
154 catch (InterruptedException ex)
155 {
156 }
157 catch (InvocationTargetException ex)
158 {
159 }
160 }
161
162
163 /*package*/ void finish()
164 {
165 SwingUtilities.invokeLater(
166 new Runnable()
167 {
168 public void run()
169 {
170 frame_.dispose();
171 }
172 });
173 }
174 }