
/**
 * AboutDialog.java
 * This class displays stuff, like who wrote this software and version of
 * The software
 *
 * Created: Fri Jul 16 19:34:21 1999
 *
 * @author Nathan Stevens
 * @version 0.22 6/24/05
 */
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class AboutDialog extends JDialog implements ActionListener {

    private ImageIcon instruViewImage;
    private JPanel panel_1;

    public AboutDialog(InstruView instruView, String title, String[] message) {
        // call the super constructer
        super(instruView.instruViewFrame, title, true);

        // the main panel and Jlabel
        panel_1 = new JPanel();

        // set the layout to grid bag layout
        GridBagLayout layout = new GridBagLayout();
        GridBagConstraints cts = new GridBagConstraints();
        panel_1.setLayout(layout);

        // put stuff in the northen position
        cts.weightx = cts.weighty = 10.0;
        cts.fill = cts.BOTH;

        String image1 = instruView.imageDirectory + "instruview.png";
        instruViewImage = new ImageIcon(image1);
        Font font = new Font("Serif", Font.BOLD + Font.ITALIC, 18);
        JLabel pic = new JLabel("InstruView", instruViewImage, JLabel.CENTER);
        pic.setFont(font);
        layout.setConstraints(pic, cts);
        panel_1.add(pic);

        // now add the text message center
        cts.insets = new Insets(0, 0, 0, 0);
        cts.gridx = 0;
        cts.gridwidth = 1;

        for (int i = 0; i < message.length; i++) {
            addMessage(message[i], cts, layout);
        }

        // add pan1 to the center position
        getContentPane().add(panel_1, BorderLayout.CENTER);

        // finally add the ok button
        JPanel panel_2 = new JPanel();
        panel_2.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 5));

        JButton button_1 = new JButton("  OK  ");
        button_1.addActionListener(this);
        button_1.setActionCommand("ok");
        panel_2.add(button_1);

        getContentPane().add(panel_2, BorderLayout.SOUTH);

        // now make this visible
        setSize(300, 170);
        setResizable(false);
        setVisible(true);
    }

    // Method to add a Line of the message array to the panel
    private void addMessage(String line, GridBagConstraints cts, GridBagLayout layout) {
        JLabel label = new JLabel(line, JLabel.CENTER);
        layout.setConstraints(label, cts);
        panel_1.add(label);
    }

    // Method to handel action events
    public void actionPerformed(ActionEvent ae) {
        String cmd = ae.getActionCommand();

        if (cmd.equals("ok")) {
            setVisible(false);
            dispose();
        }
    }
} // --AboutDialog


