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();
	}
}