View Javadoc

1   /*
2   
3   nextobjects Copyright (C) 2001-2005 Emmanuel Florent
4   
5   This program is free software; you can redistribute it and/or modify
6   it under the terms of the GNU General Public License as published by the
7   Free Software Foundation; either version 2 of the License, or (at your
8   option) any later version.
9   
10  This program is distributed in the hope that it will
11  be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12  of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13  PURPOSE. See the GNU General Public License for more details.
14  
15  You should have received a copy of the GNU General Public License along
16  with this program; if not, write to the Free Software Foundation, Inc., 59
17  Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  
19  */
20  
21  package org.devaki.nextobjects.ui.main;
22  
23  import java.awt.Color;
24  import java.awt.Cursor;
25  import java.awt.Dimension;
26  import java.awt.Frame;
27  import java.awt.Toolkit;
28  import java.awt.BorderLayout;
29  import java.awt.Window;
30  import javax.swing.BorderFactory;
31  import javax.swing.JLabel;
32  import javax.swing.JPanel;
33  import javax.swing.JProgressBar;
34  import javax.swing.ImageIcon;
35  
36  /***
37   * This class shows the splash screen during the program loading
38   */
39  public class SplashScreen extends Window
40  {
41      /***
42       * The main window of the splashscreen
43       */
44      private JPanel jPanelMain= new JPanel(new BorderLayout());
45  
46      /***
47       * The splashscreen progressbar
48       */
49      public JProgressBar jProgressBar1= new JProgressBar();
50  
51      /***
52       * Create a new 'SplashScreen' object
53       */
54      public SplashScreen()
55      {
56          super(new Frame());
57  
58          // Get current classloader
59          ClassLoader cl= this.getClass().getClassLoader();
60          JLabel jLabelImage= new JLabel(new ImageIcon(cl.getResource("org/devaki/nextobjects/icons/splash.png")));
61  
62          this.setCursor(new Cursor(Cursor.WAIT_CURSOR));
63          jProgressBar1.setStringPainted(true);
64          Toolkit tk= this.getToolkit();
65  
66          // Define the size of the window
67          this.setSize(new Dimension(550, 355));
68          // Center the window
69          int x= (tk.getScreenSize().width - 550) / 2;
70          int y= (tk.getScreenSize().height - 355) / 2;
71          this.setLocation(x, y);
72  
73          //Components 
74          // Panels
75          this.jPanelMain.setBorder(BorderFactory.createLineBorder(Color.black));
76  
77          // Assembling components
78          // jPanelMain
79          this.jPanelMain.add(jLabelImage, BorderLayout.CENTER);
80          this.jPanelMain.add(jProgressBar1, BorderLayout.SOUTH);
81          // Content Panel
82          this.add(jPanelMain);
83      }
84  }