/*
 * Created on Sep 18, 2003

 */
package Interface;

import com.jeans.trayicon.*;

import java.awt.*;
import java.awt.event.*;

import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.*;
import javax.swing.border.*;

/**
 * @author student

 * This class is being used for create a JDailog About Box for the Pinboard application
 * 
 */
//  about box for demo app
public class AboutBox extends JDialog {

	// Create new about box given parent frame
	public AboutBox(JFrame parent) {
		// Make modal dialog given parent and title
		super(parent, "About TrayIcon", true);
		// Layout stuff
		JPanel panel = new JPanel();
		panel.setLayout(new BorderLayout(3, 3));
		JPanel txt = new JPanel();
		txt.setLayout(new GridLayout(0, 1));
		txt.add(new JLabel("Pinboard version: " + "1.0"));
		txt.add(
			new JLabel(
				"OS version: " + WindowsTrayIcon.getWindowsVersionString()));
		txt.add(
			new JLabel("Written by 340 Project Team "));
		panel.add(txt, BorderLayout.CENTER);
		JPanel buttons = new JPanel();
		buttons.setLayout(new FlowLayout());
		JButton button = new JButton("OK");
		buttons.add(button, BorderLayout.CENTER);
		panel.add(buttons, BorderLayout.SOUTH);
		// Close listeners for OK button and window button
		button.addActionListener(new CloseListener());
		addWindowListener(new CloseWindowListener());
		panel.setBorder(new EmptyBorder(4, 4, 4, 4));
		setContentPane(panel);
		pack();
	}
	// Close listener for OK button
	private class CloseListener implements ActionListener {

		public void actionPerformed(ActionEvent evt) {
			dispose();
		}
	}

	// Close listener for windows button
	private class CloseWindowListener extends WindowAdapter {

		public void windowClosing(WindowEvent evt) {
			dispose();
		}
	}
}