import java.awt.*;
import javax.swing.*;

/**
 * An example that uses a combobox.
 *
 * @version 1.0
 * @author  Prof. David Bernstein, James Madison Univeristy
 */
public class ComboBoxDriver
{

    /**
     * The entry point of the example
     *
     * @param args   The command line arguments
     */
    public static void main(String[] args)
    {
        Container     contentPane;
	JFrame        frame;
        JComboBox     comboBox;
        JLabel        titleLabel;

	frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);       

	contentPane = frame.getContentPane();
	contentPane.setLayout(new BorderLayout());

	titleLabel = new JLabel();
	titleLabel.setText("A ComboBox Example");
	contentPane.add(titleLabel, BorderLayout.NORTH);

	String[] data = new String[5];
	data[0] = "CS149";
	data[1] = "CS159";
	data[2] = "CS240";
	data[3] = "CS261";
	data[4] = "CS345";

	comboBox = new JComboBox(data);
	comboBox.setEditable(true);
	contentPane.add(comboBox, BorderLayout.SOUTH);

        // Setup the observer
        ComboBoxHandler handler = new ComboBoxHandler();
        comboBox.addItemListener(handler);

        
	frame.setSize(400,200);
	frame.setVisible(true);
    }
}
