import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.applet.Applet;

public class PotatoStackRunner extends Applet implements ActionListener
{
    JLabel pic;

    JLabel toStringLbl, sizeLbl;

    Color backgroundColour = new Color (214, 62, 25);
    Color buttonColour = new Color (237, 195, 23);
    Color buttonText = Color.black;
    Color titleColour = new Color (255, 255, 255);
    Font titleFont = new Font ("Arial", Font.PLAIN, 30);
    Font promptFont = new Font ("Arial", Font.PLAIN, 20);
    Dimension boardSquare = new Dimension (115, 164);

    Potato p = new Potato ();
    PotatoStack s = new PotatoStack ();

    public void init ()
    {
	//set up stack, potato


	//set up labels & pic
	setBackground (backgroundColour);
	resize (350, 550);
	JLabel title = new JLabel ("Run Your Potato Stack");
	title.setFont (titleFont);
	title.setForeground (titleColour);

	pic = new JLabel (createImageIcon (p.getPicName ()));
	pic.setBackground (backgroundColour);
	pic.setPreferredSize (boardSquare);

	toStringLbl = new JLabel ("Top: " + p.getPicName ());
	toStringLbl.setPreferredSize (new Dimension (350, 20));
	toStringLbl.setHorizontalAlignment (0);
	toStringLbl.setForeground (titleColour);

	sizeLbl = new JLabel ("Stack Size: " + s.size ());
	sizeLbl.setPreferredSize (new Dimension (350, 20));
	sizeLbl.setHorizontalAlignment (0);
	sizeLbl.setForeground (titleColour);

	//Create the buttons
	JButton pop = new JButton ("Pop");
	pop.setForeground (buttonText);
	pop.setFont (titleFont);
	pop.setBackground (buttonColour);
	pop.setPreferredSize (new Dimension (200, 40));
	pop.setActionCommand ("pop");
	pop.addActionListener (this);

	JButton peek = new JButton ("Peek");
	peek.setForeground (buttonText);
	peek.setFont (titleFont);
	peek.setBackground (buttonColour);
	peek.setPreferredSize (new Dimension (200, 40));
	peek.setActionCommand ("peek");
	peek.addActionListener (this);

	JButton size = new JButton ("Size");
	size.setForeground (buttonText);
	size.setFont (titleFont);
	size.setBackground (buttonColour);
	size.setPreferredSize (new Dimension (200, 40));
	size.setActionCommand ("size");
	size.addActionListener (this);

	JButton isEmpty = new JButton ("isEmpty");
	isEmpty.setForeground (buttonText);
	isEmpty.setFont (titleFont);
	isEmpty.setBackground (buttonColour);
	isEmpty.setPreferredSize (new Dimension (200, 40));
	isEmpty.setActionCommand ("isEmpty");
	isEmpty.addActionListener (this);

	JButton isFull = new JButton ("isFull");
	isFull.setForeground (buttonText);
	isFull.setFont (titleFont);
	isFull.setBackground (buttonColour);
	isFull.setPreferredSize (new Dimension (200, 40));
	isFull.setActionCommand ("isFull");
	isFull.addActionListener (this);

	JButton shuffle = new JButton ("Shuffle");
	shuffle.setForeground (buttonText);
	shuffle.setFont (titleFont);
	shuffle.setBackground (buttonColour);
	shuffle.setPreferredSize (new Dimension (200, 40));
	shuffle.setActionCommand ("shuffle");
	shuffle.addActionListener (this);

	JLabel spacer = new JLabel ();
	spacer.setPreferredSize (new Dimension (350, 1));

	add (title);
	add (pic);
	add (spacer);
	add (toStringLbl);
	add (sizeLbl);
	add (pop);
	add (peek);
	add (size);
	add (isEmpty);
	add (isFull);
	add (shuffle);
    }


    public void actionPerformed (ActionEvent e)
    {
	if (e.getActionCommand ().equals ("pop"))
	{

	}
	else if (e.getActionCommand ().equals ("peek"))
	{

	}
	else if (e.getActionCommand ().equals ("size"))
	{

	}
	else if (e.getActionCommand ().equals ("isEmpty"))
	{


	}
	else if (e.getActionCommand ().equals ("isFull"))
	{

	}
	else if (e.getActionCommand ().equals ("shuffle"))
	{

	}
    }


    protected static ImageIcon createImageIcon (String path)
    {
	java.net.URL imgURL = MakeAPotato.class.getResource (path);
	if (imgURL != null)
	{
	    return new ImageIcon (imgURL);
	}
	else
	{
	    System.err.println ("Couldn't find file: " + path);
	    return null;
	}
    }
}


