// This Class is (c)opyright 1999 by Geoff Knagge. It may be freely used
// for any non-commercial purpose on the following conditions:
//   1.	You indemnify the copyright holder of all possible liability
//  	resulting from its use.
//   2.	You provide a link back to the source of this file, that is
//	http://browse.to/gogogeoff
//
// Use of this class shows your agreement to the above.

import java.awt.*;
import java.awt.event.*;

public class PNZAnswer extends Dialog implements ActionListener, 
						WindowListener {

	ColourPanel thisGuessPanel;
	Button OK;

	/// these are needed to implement WindowListener classes
	public void windowClosing (WindowEvent e) {
		setVisible(false);
	}

	public void windowActivated (WindowEvent e) {}
	public void windowClosed (WindowEvent e) {}
	public void windowDeactivated (WindowEvent e) {}
	public void windowDeiconified (WindowEvent e) {}
	public void windowIconified (WindowEvent e) {}
	public void windowOpened (WindowEvent e) {}

	
	/// needed to implement the ActionListener
	public void actionPerformed(ActionEvent e) {
		setVisible(false);
	}


	public PNZAnswer(Frame f,PNZColours parent,int[] target,
				String title) {
	// inputs : Frame to tie the Dialog to, the calling class,
	//		the array of winning colours, dialog title
		super(f,title,true);
		setBackground(new Color(96,192,255));

		setLayout(new GridLayout(3,1));
		Label thisGuess = new Label("The winning combination was as follows :");
		thisGuessPanel = new ColourPanel(parent,"", target.length, true);

		for (int cnt=0; cnt<target.length; cnt++)
			thisGuessPanel.setPanel(cnt,target[cnt]);
		OK = new Button(" OK ");
		add(thisGuess);
		add(thisGuessPanel);
		add(OK);
		OK.addActionListener(this);
		addWindowListener(this);
		}

	public static void showAnswers(Frame f,PNZColours parent,
					int[] target,String title) {
		PNZAnswer Q = new PNZAnswer(f,parent,target,title);
		Q.setSize(400,200);
		Q.setVisible(true);
		Q.dispose();
		}


}
