//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
	private JButton 
	   cmdStart, 
	   cmdExit;
	private String myB1,myB2;
	private boolean debug;
	
	public ControlPanel()
	{
		super();
		//I made the button captions into variables so that the values
		//could be changed in one place. 
		debug = false;
		myB1="Start";
		myB2="Exit  ";	
		//causes buttons to stack and be normal sized
		setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
		
	    cmdStart = new JButton(myB1);
	    cmdExit  = new JButton(myB2);

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

		
		//add(cmdStart);
		add(cmdExit);

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