//Control Panel for Hangman
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class ControlPanel extends JPanel implements ActionListener
{
	//A ControlPanel is a JPanel with a collection of JButtons on it
	//This allows the programmer to add command buttons to the program
	//and define their actions in a systematic way
	JButton 
	   cmdStart, 
	   cmdExit;
	String B1,B2;
	
	public ControlPanel()
	{
		super();
		//I made the button captions into variables so that the values
		//could be changed in one place. 
		B1="Start";
		B2="Exit  ";	
		//causes buttons to stack and be normal sized
		setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
		
	    cmdStart = new JButton(B1);
	    cmdExit  = new JButton(B2);

	    
		cmdStart.addActionListener(this);
		cmdExit.addActionListener(this);

		
		add(cmdStart);
		add(cmdExit);

			
	}
	public void actionPerformed(ActionEvent ae)
	{
		String command = ae.getActionCommand();
		
		if (command.equals(B2)) 
		   	System.exit(0);
		else if (command.equals(B1))
		   	System.out.println(B1);
		else if (command.equals("Other"))
			System.out.println("Other");
			
		System.out.println("Real Command: "+ae.getActionCommand());
		
	}
}
