/*
	A basic extension of the java.awt.Dialog class
 */

import java.awt.*;

public class AboutDlg extends Dialog {

	public AboutDlg(Frame parent, boolean modal, String title, String label) {
		super(parent, modal);
		// INIT_CONTROLS
		setLayout(null);
		setBackground(java.awt.Color.lightGray);
		setSize(249, 150);
		setVisible(false);
		mainLabel.setText(label);
		add(mainLabel);
		mainLabel.setBounds(25, 30, 200, 21);
		mainLabel.setAlignment(java.awt.Label.CENTER);
		okButton.setLabel("OK");
		add(okButton);
		okButton.setBounds(91, 112, 66, 24);
		label1.setText("v. 1.00");
		label1.setAlignment(java.awt.Label.CENTER);
		add(label1);
		label1.setBounds(51, 58, 166, 21);
		setTitle("About " + title);
        
		// REGISTER_LISTENERS
		SymWindow aSymWindow = new SymWindow();
		this.addWindowListener(aSymWindow);
		SymAction lSymAction = new SymAction();
		okButton.addActionListener(lSymAction);
	}
    
	public void addNotify() {
		// Record the size of the window prior to calling parents addNotify.
		Dimension d = getSize();

		super.addNotify();

		// Only do this once.
		if (fComponentsAdjusted)
			return;

		// Adjust components according to the insets
		Insets insets = getInsets();
		setSize(insets.left + insets.right + d.width, insets.top + insets.bottom + d.height);
		Component components[] = getComponents();
		for (int i = 0; i < components.length; i++) {
			Point p = components[i].getLocation();
			p.translate(insets.left, insets.top);
			components[i].setLocation(p);
		}

		// Used for addNotify check.
		fComponentsAdjusted = true;
	}

	public void setVisible(boolean b) {
	    if (b) {
    		Rectangle bounds  = getParent().getBounds();
    		Rectangle abounds = getBounds();
    		setLocation(bounds.x + (bounds.width - abounds.width)/ 2, 
    			 		bounds.y + (bounds.height - abounds.height)/2);
	    }
		super.setVisible(b);
	}

	// DECLARE_CONTROLS
	java.awt.Label mainLabel = new java.awt.Label();
	java.awt.Button okButton = new java.awt.Button();
	java.awt.Label label1    = new java.awt.Label();
    
    // Used for addNotify check.
	boolean fComponentsAdjusted = false;

	class SymAction implements java.awt.event.ActionListener {
		public void actionPerformed(java.awt.event.ActionEvent event) {
			Object object = event.getSource();
			if (object == okButton)
				okButton_ActionPerformed(event);
		}
	}

	void okButton_ActionPerformed(java.awt.event.ActionEvent event) {
		okButton_ActionPerformed_Interaction1(event);
	}


	void okButton_ActionPerformed_Interaction1(java.awt.event.ActionEvent event) {
		try {
			this.dispose();
		} catch (Exception e) {
		}
	}

	class SymWindow extends java.awt.event.WindowAdapter {
		public void windowClosing(java.awt.event.WindowEvent event) {
			Object object = event.getSource();
			if (object == AboutDlg.this)
				AboutDlg_WindowClosing(event);
		}
	}

	void AboutDlg_WindowClosing(java.awt.event.WindowEvent event) {
		AboutDlg_WindowClosing_Interaction1(event);
	}

	void AboutDlg_WindowClosing_Interaction1(java.awt.event.WindowEvent event) {
		try {
			this.dispose();
		} catch (Exception e) {
		}
	}

}
