import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.applet.Applet;

public class GuessCard extends Applet implements ActionListener
{
    JLabel pic;

    JComboBox suitChoice, numberChoice;
    JTextArea oldHints;

    Card c = new Card ();
    Card secret = new Card ();

    Color backgroundColour = new Color (68, 133, 191);
    Color buttonColour = new Color (48, 95, 136);
    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 (140, 190);

    public void init ()
    {
	setBackground (backgroundColour);
	resize (350, 500);
	JLabel title = new JLabel ("Guess Which Card");
	title.setFont (titleFont);
	title.setForeground (titleColour);

	pic = new JLabel (createImageIcon (c.getPicName ()));
	pic.setBackground (backgroundColour);
	pic.setPreferredSize (boardSquare);

	secret.setRandomCard ();
	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[] suitStrings = {"Clubs", "Diamonds", "Hearts", "Spades"};
	suitChoice = new JComboBox (suitStrings);
	suitChoice.setSelectedIndex (0);
	suitChoice.setActionCommand ("suit");
	suitChoice.addActionListener (this);
	suitChoice.setFont (promptFont);
	suitChoice.setPreferredSize (new Dimension (150, 40));
	suitChoice.setBackground (buttonColour);
	suitChoice.setForeground (buttonText);

	String[] numberStrings = {"1 (Ace)", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11 (Jack)", "12 (Queen)", "13 (King)"};
	numberChoice = new JComboBox (numberStrings);
	numberChoice.setSelectedIndex (0);
	numberChoice.setActionCommand ("number");
	numberChoice.addActionListener (this);
	numberChoice.setFont (promptFont);
	numberChoice.setPreferredSize (new Dimension (150, 40));
	numberChoice.setBackground (buttonColour);
	numberChoice.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 (suitChoice);
	add (numberChoice);
	add (oldHints);
	add (hint);
    }


    public void actionPerformed (ActionEvent e)
    {
	if (e.getActionCommand ().equals ("suit"))
	{
	  
	}
	else if (e.getActionCommand ().equals ("number"))
	{
	    String s = (String) numberChoice.getSelectedItem ();
	    int n = Integer.parseInt (s.charAt (0) + "");
	    if (s.length () > 1)
		n = Integer.parseInt (s.substring (0, 2).trim ());

	   
	}
	else if (e.getActionCommand ().equals ("hint"))
	{

	}
	else if (e.getActionCommand ().equals ("reset"))
	{

	}


    }


    protected static ImageIcon createImageIcon (String path)
    {
	java.net.URL imgURL = GuessCard.class.getResource (path);
	if (imgURL != null)
	{
	    return new ImageIcon (imgURL);
	}
	else
	{
	    System.err.println ("Couldn't find file: " + path);
	    return null;
	}
    }
}


