package com.tagtraum.perf.gcviewer;

import javax.swing.*;
import javax.swing.border.BevelBorder;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.*;
import java.util.ResourceBundle;


/**
 * About dialog.
 *
 * @author  Hendrik Schreiber
 * @version $Id: $
 */
public class AboutDialog extends JDialog implements ActionListener {

    /**
     * Source-Version
     */
    public static String vcid = "$Id: AboutDialog.java,v 1.1.1.1 2002/01/15 19:48:45 hendriks73 Exp $";
    private static ResourceBundle localStrings = ResourceBundle.getBundle("com.tagtraum.perf.gcviewer.localStrings");

    private Frame frame;

    public AboutDialog(Frame f) {
        super(f, localStrings.getString("about_dialog_title"), true);
        this.frame = f;
        setLocation(20, 20);
        Panel panel0 = new Panel();
        ImageIcon logoIcon = new ImageIcon(getClass().getResource(localStrings.getString("about_dialog_image")));
        JLabel la_icon = new JLabel(logoIcon);
        panel0.add(la_icon);
        Panel panel2 = new Panel();
        panel2.setLayout(new FlowLayout(FlowLayout.RIGHT));
        JButton theOKButton = new JButton(localStrings.getString("button_ok"));
        theOKButton.setActionCommand("ok");
        theOKButton.addActionListener(this);
        panel2.add(theOKButton);
        getContentPane().add("North", panel0);
        // getContentPane().add("Center",panel1);
        getContentPane().add("South", panel2);
        pack();
        setVisible(false);
    }

    public void actionPerformed(ActionEvent e) {
        String cmd = e.getActionCommand();
        if (cmd.equals("ok")) {
            setVisible(false);
        }
    }

    public void setVisible(boolean visible) {
        if (visible) setLocation((int)frame.getLocation().getX() + 50, (int)frame.getLocation().getY() + 50);
        super.setVisible(visible);
    }
}
