KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > ejtools > deploy > SplashWindow


1 /*
2  * EJTools, the Enterprise Java Tools
3  *
4  * Distributable under LGPL license.
5  * See terms of license at www.gnu.org.
6  */

7 package net.sourceforge.ejtools.deploy;
8
9 // Standard Imports
10
import java.awt.BorderLayout JavaDoc;
11 import java.awt.Dimension JavaDoc;
12 import java.awt.Toolkit JavaDoc;
13
14 import javax.swing.ImageIcon JavaDoc;
15 import javax.swing.JLabel JavaDoc;
16 import javax.swing.JPanel JavaDoc;
17 import javax.swing.JProgressBar JavaDoc;
18 import javax.swing.JWindow JavaDoc;
19 import javax.swing.SwingUtilities JavaDoc;
20
21 /**
22  * Description of the Class
23  *
24  * @author letiembl
25  * @created 2 novembre 2001
26  * @todo Javadoc to complete
27  */

28 public class SplashWindow extends JWindow JavaDoc
29 {
30    /** Description of the Field */
31    protected JPanel JavaDoc panel = null;
32    /** Description of the Field */
33    protected JLabel JavaDoc message = null;
34    /** Description of the Field */
35    protected JProgressBar JavaDoc progressBar = null;
36    /** Description of the Field */
37    protected int length = 0;
38
39
40    /**
41     *Constructor for the SplashWindow object
42     *
43     * @param message Description of Parameter
44     * @param length Description of Parameter
45     */

46    public SplashWindow(String JavaDoc message, int length)
47    {
48       this.length = length;
49       this.message = new JLabel JavaDoc(message);
50       this.createPanel();
51       this.setContentPane(panel);
52       this.pack();
53
54       Dimension JavaDoc screen = Toolkit.getDefaultToolkit().getScreenSize();
55       this.setLocation(screen.width / 2 - this.getSize().width / 2, screen.height / 2 - this.getSize().height / 2);
56    }
57
58
59    /**
60     * Description of the Method
61     *
62     * @param message Description of Parameter
63     */

64    public void progress(String JavaDoc message)
65    {
66       this.message.setText(message);
67
68       int value = this.progressBar.getValue();
69       value++;
70       this.progressBar.setValue(value);
71
72       SwingUtilities.invokeLater(
73          new Runnable JavaDoc()
74          {
75             public void run()
76             {
77                repaint();
78             }
79          });
80    }
81
82
83    /** Description of the Method */
84    protected void createPanel()
85    {
86       panel = new JPanel JavaDoc(new BorderLayout JavaDoc());
87
88       // North part
89
panel.add("North", new JLabel JavaDoc(new ImageIcon JavaDoc(getClass().getResource("/images/logo.png"))));
90
91       // Center part
92
panel.add("Center", message);
93
94       // South part
95
progressBar = new JProgressBar JavaDoc(0, this.length);
96       progressBar.setValue(0);
97       progressBar.setStringPainted(false);
98       progressBar.setBorderPainted(false);
99       panel.add("South", progressBar);
100    }
101 }
102
103
104
Popular Tags