/***********************************************************************

GECCO, a platform for command and control gaming

Copyright (C) 2001 Henrik Bäärnhielm, Andreas Enblom, Niklas
Hallenfur, Karl Hasselström, Henrik Hägerström, Oskar Linde, Jing Fu
Zi and Jon Åslund

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 gecco.client.dialogs;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

/**
 *  This class supplies a modal dialog that displays info about the game.
 *
 * @author     Andreas Enblom
 * @created    June 27, 2001
 */
public class GameInfo {
    /**
     *  Description of the Field
     */
    private static JDialog dialog;
    // the dialog box
    /**
     *  Description of the Field
     */
    private static JPanel content;
    // dialog box's contents
    /**
     *  Description of the Field
     */
    private static JButton okButton;
    // button of dialog


    /**
     *  No contructor is necessary.
     */
    private GameInfo() {
    }


    /**
     *  Displays the game info dialog.
     *
     * @param  owner  The frame that owns the modal dialog.
     */
    public static void display(Frame owner) {
        dialog = new JDialog(owner, "About", true);
        dialog.getContentPane().setLayout(new BorderLayout());
        dialog.getContentPane().add(content);
        dialog.getRootPane().setDefaultButton(okButton);
        dialog.pack();
        dialog.setLocationRelativeTo(owner);
        dialog.setVisible(true);
    }

    static {
        JLabel credits = new JLabel();
        credits.setText("<html><center>" +
                "<h2>GECCO version 1.0</h2>" +
                "<p><b>Created by</b></p>" +
                "<p>Henrik B&auml;&auml;rnhielm</p>" +
                "<p>Andreas Enblom</p>" +
                "<p>Jing Fu Zi</p>" +
                "<p>Niklas Hallenfur</p>" +
                "<p>Karl Hasselstr&ouml;m</p>" +
                "<p>Henrik H&auml;gerstr&ouml;m</p>" +
                "<p>Oskar Linde</p>" +
                "<p>Jon &Aring;slund</p>" +
                "<p></p></center></html>");
        credits.setAlignmentX(Component.CENTER_ALIGNMENT);

        okButton = new JButton("OK");
        okButton.addActionListener(
            new ActionListener() {
                /**
                 *  Description of the Method
                 *
                 * @param  e  Description of Parameter
                 */
                public void actionPerformed(ActionEvent e) {
                    dialog.setVisible(false);
                }
            });
        okButton.setAlignmentX(Component.CENTER_ALIGNMENT);

        int fill = 10;
        // amount of white space
        content = new JPanel();
        content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));
        content.setBorder(BorderFactory.createEmptyBorder(fill, fill,
                fill, fill));
        content.add(credits);
        content.add(Box.createVerticalStrut(fill));
        content.add(okButton);
    }
}
