/*
 Tiamat - a role-playing game framework
 AboutSplash.java - splash screen to display if the Tiamat Framework jar file is executed
 
 Copyright  (C) 2004-2005 Hugues Johnson
 
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
 
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
 the GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

package com.huguesjohnson.tiamat;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.WindowConstants;

/**
 * AboutSplash splash screen to display if the Tiamat Framework jar file is executed
 * @author Hugues Johnson
 */
public class AboutSplash extends javax.swing.JFrame{

	/** Determines if a de-serialized file is compatible with this class. See <a href="http://java.sun.com/j2se/1.5.0/docs/guide/serialization/spec/class.html">Java Object Serialization Specifications</a>. */
	private static final long serialVersionUID=5437017308425957864L;

	/** Creates new form AboutSplash */
	public AboutSplash(){
		this.initComponents();
		this.centerWindow();
	}

	private void centerWindow(){
		Dimension screenDimension=Toolkit.getDefaultToolkit().getScreenSize();
		Rectangle windowDimension=this.getBounds();
		this.setLocation((screenDimension.width-windowDimension.width)/2,(screenDimension.height-windowDimension.height)/2);
	}

	private void initComponents(){
		this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
		this.setTitle("Tiamat");
		this.setResizable(false);
		this.setUndecorated(true);
		this.addWindowListener(new WindowAdapter(){
			public void windowClosing(WindowEvent evt){
				exitForm();
			}
		});

		JLabel label=new JLabel();
		label.setIcon(new ImageIcon(getClass().getResource("/com/huguesjohnson/tiamat/about_tiamat.gif")));
		label.addMouseListener(new MouseAdapter(){
			public void mouseClicked(MouseEvent evt){
				exitForm();
			}
		});
		this.getContentPane().add(label,BorderLayout.CENTER);
	
		this.pack();
	}

	/** Exit the Application */
	public void exitForm(){
		System.exit(0);
	}
	
	/** Entry point for application.
	 * @param arguments Command-line arguments, ignored.
	 */
	public static void main(String[] arguments){
		(new AboutSplash()).setVisible(true);
	}
}