import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.applet.Applet;

public class GuessPotato extends Applet implements ActionListener
{
    JLabel pic;

    JComboBox crownChoice, glovesChoice, underpantsChoice, typeChoice;
    JTextArea oldHints;

    Potato p = new Potato ();
    Potato secret = new Potato ();

    Color backgroundColour = new Color (244, 218, 111);
    Color buttonColour = new Color (214, 62, 25);
    Color buttonText = new Color (255, 255, 255);
    Color titleColour = Color.black;
    Font titleFont = new Font ("Arial", Font.PLAIN, 30);
    Font promptFont = new Font ("Arial", Font.PLAIN, 20);
    Dimension boardSquare = new Dimension (115, 164);

    public void init ()
    {
	setBackground (backgroundColour);
	resize (350, 540);
	JLabel title = new JLabel ("Guess the Secret Pototo");
	title.setFont (titleFont);
	title.setForeground (titleColour);

	pic = new JLabel (createImageIcon (p.getPicName ()));
	pic.setBackground (backgroundColour);
	pic.setPreferredSize (boardSquare);

	secret.setRandomPotato ();
	JButton reset = new JButton ("Reset");
	reset.setBackground (buttonColour);
	reset.setForeground (buttonText);
	reset.setFont (promptFont);
	reset.setActionCommand ("reset");
	reset.addActionListener (this);

	//Create the combo boxes
	String[] typeStrings = {"brown", "chip", "fry", "purple"};
	typeChoice = new JComboBox (typeStrings);
	typeChoice.setSelectedIndex (0);
	typeChoice.setActionCommand ("type");
	typeChoice.addActionListener (this);
	typeChoice.setFont (promptFont);
	typeChoice.setPreferredSize (new Dimension (150, 40));
	typeChoice.setBackground (buttonColour);
	typeChoice.setForeground (buttonText);

	String[] crownStrings = {"crown", "none"};
	crownChoice = new JComboBox (crownStrings);
	crownChoice.setSelectedIndex (0);
	crownChoice.setActionCommand ("crown");
	crownChoice.addActionListener (this);
	crownChoice.setFont (promptFont);
	crownChoice.setPreferredSize (new Dimension (150, 40));
	crownChoice.setBackground (buttonColour);
	crownChoice.setForeground (buttonText);

	String[] glovesStrings = {"gloves", "none"};
	glovesChoice = new JComboBox (glovesStrings);
	glovesChoice.setSelectedIndex (0);
	glovesChoice.setActionCommand ("gloves");
	glovesChoice.addActionListener (this);
	glovesChoice.setFont (promptFont);
	glovesChoice.setPreferredSize (new Dimension (150, 40));
	glovesChoice.setBackground (buttonColour);
	glovesChoice.setForeground (buttonText);

	String[] underpantsStrings = {"underpants", "none"};
	underpantsChoice = new JComboBox (underpantsStrings);
	underpantsChoice.setSelectedIndex (0);
	underpantsChoice.setActionCommand ("underpants");
	underpantsChoice.addActionListener (this);
	underpantsChoice.setFont (promptFont);
	underpantsChoice.setPreferredSize (new Dimension (150, 40));
	underpantsChoice.setBackground (buttonColour);
	underpantsChoice.setForeground (buttonText);

	JButton hint = new JButton ("Hint");
	hint.setBackground (buttonColour);
	hint.setForeground (buttonText);
	hint.setFont (promptFont);
	hint.setActionCommand ("hint");
	hint.addActionListener (this);

	oldHints = new JTextArea (15, 27);
	oldHints.setFont (new Font ("Arial", Font.BOLD, 10));
	oldHints.setBackground (buttonColour);
	oldHints.setForeground (buttonText);
	oldHints.setLineWrap (true);
	oldHints.setEditable (false);

	JLabel spacer = new JLabel ();
	spacer.setPreferredSize (new Dimension (350, 1));

	add (title);
	add (pic);
	add (reset);
	add (spacer);
	add (typeChoice);
	add (crownChoice);
	add (glovesChoice);
	add (underpantsChoice);
	add (oldHints);
	add (hint);
    }


    public void actionPerformed (ActionEvent e)
    {
	if (e.getActionCommand ().equals ("type"))
	{
	   
	}
	else if (e.getActionCommand ().equals ("underpants"))
	{
	   
	}
	else if (e.getActionCommand ().equals ("crown"))
	{
	  
	}
	else if (e.getActionCommand ().equals ("gloves"))
	{

	}
	else if (e.getActionCommand ().equals ("hint"))
	{
	   
	}
	else if (e.getActionCommand ().equals ("reset"))
	{
	    
	}
    }


    protected static ImageIcon createImageIcon (String path)
    {
	java.net.URL imgURL = GuessPotato.class.getResource (path);
	if (imgURL != null)
	{
	    return new ImageIcon (imgURL);
	}
	else
	{
	    System.err.println ("Couldn't find file: " + path);
	    return null;
	}
    }
}
