/* This page is part of the Game of Life source code */

package org.bitstorm.util;

import java.awt.AWTEvent;
import java.awt.Button;
import java.awt.Dialog;
import java.awt.Event;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.Label;
import java.awt.Panel;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;


/**
 * Shows a constructed About dialog box.
 * The dialog box can contain an image and several lines of text.
 *
 @author Edwin Martin
 */
public class AboutDialog extends Dialog {
  private Button okButton;

    /**
     * Construct a AboutDialog.
   @param parent parent Frame
   @param title title of dialog
   @param imageName image to show
   @param posX x-coordinate
   @param posY y-coordinate
   */
  public AboutDialogFrame parent, String title, String[] lines, String imageName, int posX, int posY ) {
        superparent, title, false );

        Image image = Toolkit.getDefaultToolkit().getImage(this.getClass().getResource(imageName));
    ImageComponent ic = new ImageComponentimage );
    okButton = new Button("   OK   ");
    okButton.addActionListener(
      new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          close();
        }
      }
    );
  
        GridBagLayout gridbag = new GridBagLayout();
        GridBagConstraints contraints = new GridBagConstraints();
        setLayout(gridbag);

        Panel buttonPanel = new Panel();
    buttonPanel.setLayoutnew FlowLayoutFlowLayout.CENTER ) );
    buttonPanel.addokButton );

    Panel textPanel = new Panel();
    textPanel.setLayoutnew GridLayoutlines.length, ) );
    for (int i=0; i<lines.length; i++) {
      textPanel.add(new Label(lines[i]));
    }
    contraints.fill = GridBagConstraints.BOTH;
    contraints.weightx = 1;
        contraints.weighty = 1;
        contraints.gridx = GridBagConstraints.REMAINDER;
        contraints.gridy = 0;
        contraints.anchor = GridBagConstraints.CENTER;
        gridbag.setConstraints(ic, contraints);
    addic );
    contraints.fill = GridBagConstraints.NONE;
        contraints.weightx = 0;
        contraints.weighty = 0;
        contraints.gridy = 1;
        gridbag.setConstraints(textPanel, contraints);
    addtextPanel );
        contraints.gridy = 2;
        gridbag.setConstraints(buttonPanel, contraints);
    addbuttonPanel );

    enableEvents(Event.WINDOW_DESTROY);
    setResizablefalse );
    setModaltrue );
    pack();
    setLocationposX, posY );
    show();
    }
    
    /**
   * Close dialog box.
   */
  private void close() {
        this.hide();
        this.dispose();
    }
  /**
   * Process close window button.
   @see java.awt.Component#processEvent(java.awt.AWTEvent)
   */
  public void processEventAWTEvent e ) {
    if e.getID() == Event.WINDOW_DESTROY )
      close();
  }
}
Java2html