|
1 /* |
|
2 * Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
6 * under the terms of the GNU General Public License version 2 only, as |
|
7 * published by the Free Software Foundation. |
|
8 * |
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
|
13 * accompanied this code). |
|
14 * |
|
15 * You should have received a copy of the GNU General Public License version |
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 * |
|
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
20 * CA 95054 USA or visit www.sun.com if you need additional information or |
|
21 * have any questions. |
|
22 * |
|
23 */ |
|
24 |
|
25 |
|
26 package com.sun.java.swing.ui; |
|
27 |
|
28 import java.awt.*; |
|
29 import javax.swing.ImageIcon; |
|
30 |
|
31 public class SplashScreen extends Window |
|
32 { |
|
33 |
|
34 public SplashScreen(Frame f) |
|
35 { |
|
36 super(f); |
|
37 setBackground(Color.white); |
|
38 java.net.URL url = getClass().getResource("/images/SplashScreen.jpg"); |
|
39 if(url != null) |
|
40 { |
|
41 screen = new ImageIcon(url); |
|
42 MediaTracker mt = new MediaTracker(this); |
|
43 mt.addImage(screen.getImage(), 0); |
|
44 try |
|
45 { |
|
46 mt.waitForAll(); |
|
47 } |
|
48 catch(Exception ex) { } |
|
49 } |
|
50 } |
|
51 |
|
52 public void setVisible(boolean val) |
|
53 { |
|
54 if(screen == null) |
|
55 return; |
|
56 if(val) |
|
57 { |
|
58 setSize(screen.getIconWidth(), screen.getIconHeight()); |
|
59 setLocation(-500, -500); |
|
60 super.setVisible(true); |
|
61 Dimension d = getToolkit().getScreenSize(); |
|
62 Insets i = getInsets(); |
|
63 int w = screen.getIconWidth() + i.left + i.right; |
|
64 int h = screen.getIconHeight() + i.top + i.bottom; |
|
65 setSize(w, h); |
|
66 setLocation(d.width / 2 - w / 2, d.height / 2 - h / 2); |
|
67 } else |
|
68 { |
|
69 super.setVisible(false); |
|
70 } |
|
71 } |
|
72 |
|
73 public void paint(Graphics g) |
|
74 { |
|
75 if(screen != null) |
|
76 { |
|
77 Dimension d = getSize(); |
|
78 g.setColor(Color.black); |
|
79 g.drawRect(0, 0, d.width - 1, d.height - 1); |
|
80 g.drawImage(screen.getImage(), 1, 1, this); |
|
81 } |
|
82 } |
|
83 |
|
84 private ImageIcon screen; |
|
85 } |