import java.applet.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;

public class Baseball
	extends JApplet
{

	// A Hashtable is a built-in Java class that stores a "value"
	// using a given "key."  You can retrieve the value again
	// if you use the same key.
	//
	// The Hashtable class is part of the java.util package, so
	// don't forget to import it (see above).
	//
	// In this case, we will store the BattingAverage objects
	// as the "value" and use the player's Name object as the "key."
	//
	// The Hashtable class is part of the java.util package, so
	// don't forget to import it (see above).
	// This links the Name and BattingAverage together.
	//
	private Hashtable team = new Hashtable();

	// GUI components to represent our data.
	private JLabel message = new JLabel("Welcome", JLabel.CENTER);
	private JTextField firstName = new JTextField();
	private JTextField lastName = new JTextField();
	private JTextField hits = new JTextField();
	private JTextField atBats = new JTextField();
	private JTextField average = new JTextField();

	public void init()
	{
		Container pane = getContentPane();
		pane.setLayout(new GridBagLayout());

		// Add top message which spans the entire applet.
		GridBagConstraints gbc = new GridBagConstraints();
		gbc.weightx = 1;
		gbc.gridwidth = GridBagConstraints.REMAINDER;
		gbc.fill = GridBagConstraints.HORIZONTAL;
		pane.add(message, gbc);

		// Add labels and textfields.
		GridBagConstraints gbc1 = new GridBagConstraints();
		gbc1.fill = GridBagConstraints.HORIZONTAL;
		GridBagConstraints gbc2 = new GridBagConstraints();
		gbc2.gridwidth = GridBagConstraints.REMAINDER;
		gbc2.weightx = 10;
		gbc2.fill = GridBagConstraints.HORIZONTAL;
		pane.add(new JLabel("First:", JLabel.RIGHT), gbc1);
		pane.add(firstName, gbc2);
		pane.add(new JLabel("Last:", JLabel.RIGHT), gbc1);
		pane.add(lastName, gbc2);
		pane.add(new JLabel("Hits:", JLabel.RIGHT), gbc1);
		pane.add(hits, gbc2);
		pane.add(new JLabel("At Bats:", JLabel.RIGHT), gbc1);
		pane.add(atBats, gbc2);
		pane.add(new JLabel("Average:", JLabel.RIGHT), gbc1);
		pane.add(average, gbc2);

		// add blank label for filler.
		pane.add(new JLabel("", JLabel.RIGHT), gbc1);
		// add Buttons for control.
		JPanel p = new JPanel(new GridBagLayout());
		GridBagConstraints gbc4 = new GridBagConstraints();
		gbc4.weightx = 1;
		JButton clear = new JButton("Clear");
		JButton save = new JButton("Save");
		JButton search = new JButton("Search");
		p.add(clear, gbc4);
		p.add(save, gbc4);
		p.add(search, gbc4);
		pane.add(p, gbc2);


		// Set average to be read-only.  i.e. the use
		// can't type in it.  We (the programmer) can still
		// set its value.
		average.setEditable(false);
	}

}
