//----------------------------BEGIN LICENSE----------------------------
/* 
 * Willow : the Open Source WorkFlow Project
 * Distributable under GNU LGPL license by gun.org
 *
 * Copyright (C) 2004-2010 huihoo.org 
 * Copyright (C) 2004-2010  ZosaTapo <dertyang@hotmail.com> 
 * 
 * ====================================================================
 * Project Homepage : http://www.huihoo.org/willow
 * Source Forge     : http://sourceforge.net/projects/huihoo
 * Mailing list     : willow@lists.sourceforge.net 
 */
//----------------------------END  LICENSE----------------------------
package org.huihoo.god4j;

import java.awt.BorderLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JWindow;

import org.huihoo.god4j.util.ImageLoader;
import org.huihoo.god4j.util.ToolUtils;

/**
 * @author liangce
 *
 * To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
public class SplashWindow extends JWindow
{
	private static SplashWindow jaweSplash;

	public SplashWindow(String icon, JFrame f)
	{
		super(f);
		jaweSplash = this;
		
		JLabel l = new JLabel(ImageLoader.getImageIcon(ImageLoader.getImageName(icon)));
		getContentPane().add(l, BorderLayout.CENTER);

		pack();

		ToolUtils.centerDesktop(this,200,200);
													
		addMouseListener(new MouseAdapter()
		{
			public void mousePressed(MouseEvent e)
			{
				hideSplash();
			}
		});
		
		setVisible(true);	


	}

	public static SplashWindow getSplash()
	{
		return jaweSplash;
	}

	public void hideSplash()
	{
		if (isVisible())
		{
			setVisible(false);
			dispose();
		}
	}

}
