01: package hero.client.grapheditor;
02:
03: import javax.swing.*;
04: import java.awt.*;
05: import java.awt.event.*;
06:
07: public class SplashWindow extends JWindow {
08:
09: public SplashWindow(/*String filename,*/java.awt.Frame f,
10: Frame frame /*, int waitTime*/) {
11:
12: super (f);
13: try {
14: String filename = "images/open.gif";
15: int waitTime = 5;
16: ClassLoader cl = frame.getClass().getClassLoader();
17: JLabel l = new JLabel(new ImageIcon(cl
18: .getResource("images/Splash.gif")));
19: getContentPane().add(l, BorderLayout.CENTER);
20: pack();
21: Dimension screenSize = Toolkit.getDefaultToolkit()
22: .getScreenSize();
23: Dimension labelSize = l.getPreferredSize();
24: setLocation(screenSize.width / 2 - (labelSize.width / 2),
25: screenSize.height / 2 - (labelSize.height / 2));
26: addMouseListener(new MouseAdapter() {
27: public void mousePressed(MouseEvent e) {
28: setVisible(false);
29: dispose();
30: }
31: });
32: /*
33: final int pause = waitTime;
34: final Runnable closerRunner = new Runnable()
35: {
36: public void run()
37: {
38: setVisible(false);
39: dispose();
40: }
41: };
42: Runnable waitRunner = new Runnable()
43: {
44: public void run()
45: {
46: try
47: {
48: Thread.sleep(pause);
49: SwingUtilities.invokeAndWait(closerRunner);
50: }
51: catch(Exception e)
52: {
53: e.printStackTrace();
54: // can catch InvocationTargetException
55: // can catch InterruptedException
56: }
57: }
58: };*/
59: setVisible(true);
60: // Thread splashThread = new Thread(waitRunner, "SplashThread");
61: // splashThread.start();
62: } catch (Exception ex) {
63: ex.printStackTrace();
64: }
65: }
66: }
|