Blame view

JPAINT/jpaint/SplashScreen.java~ 1.6 KB
933d00ad   rlentieu   add JPaint
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
  import javax.swing.JLabel;

  import javax.swing.ImageIcon;

  import javax.swing.JPanel;

  import java.awt.Dimension;

  import java.awt.BorderLayout;

  import java.awt.Window;

  import java.awt.Frame;

  import java.awt.Color;

  import java.awt.Toolkit;

  

  /**

   * Splash Screen loads up for this program. Before the program runs a screen

   * with an image pops up for a second, then it loads the rest of the program.

   **/

  public class SplashScreen extends Window

  {

  	JLabel lblStatus = new JLabel("LOADING  JPaint is opening...");

  	

  	/** 

  	 * Creates a default constructor. Creates a new frame and adds the 

  	 * background image onto it.

  	 **/

  	public SplashScreen(String strImageFileName)

  	{

  		super(new Frame());

  		

  		ImageIcon imageScreen = new ImageIcon(strImageFileName);

  		JLabel lblImage = new JLabel(imageScreen);

  		lblStatus.setBackground(Color.black);

  		lblStatus.setForeground(Color.black);

  		JPanel pnlIm = new JPanel(new BorderLayout());

  		pnlIm.add(lblImage, BorderLayout.CENTER);

  		pnlIm.add(lblStatus, BorderLayout.SOUTH);

  		pnlIm.setBackground(Color.black);	

  		add(pnlIm);

  		pack();

  		

  		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

  		Dimension windowSize = getSize();

  		this.setBounds((screenSize.width - windowSize.width)/2, (screenSize.height - windowSize.height)/2, windowSize.width, windowSize.height);

  		

  		setVisible(true);

  	}

  	

  	/** Updates the status bar with the new string. **/

  	public void updateStatus(String temp)

  	{

  		lblStatus.setText(temp);

  		setVisible(true);

  	}

  	

  	/** Closes the splash screen. **/

  	public void closeWindow()

  	{

  		dispose();

  	}

  }