// A class that can be used to create a form for a person
// Barry Cornelius, 19 June 2000
import javax.swing. Box;
import javax.swing. BoxLayout;
import java.awt.    Component;
import java.awt.    Dimension;
import javax.swing. JLabel;
import javax.swing. JTextField;
import javax.swing. SwingConstants;
public class PersonForm
{
   private JTextField iNameJTextField;
   private JTextField iDateOfBirthJTextField;
   private JTextField iPhoneNumberJTextField;
   private JTextField iHeightJTextField;
   private Box iBox; //BJCHEREFIRST
   public PersonForm()
   {
      final Dimension tDimension = new Dimension(120, 20);
      // deal with the Name
      final JLabel tNameJLabel = new JLabel("Name", SwingConstants.RIGHT);
      tNameJLabel.setPreferredSize(tDimension);
      iNameJTextField = new JTextField(25);
      // deal with the NameBox
      final Box tNameBox = new Box(BoxLayout.X_AXIS);
      tNameBox.add(tNameJLabel);
      tNameBox.add(iNameJTextField);
      // deal with the DateOfBirth
      final JLabel tDateOfBirthJLabel =
                        new JLabel("DateOfBirth", SwingConstants.RIGHT);
      tDateOfBirthJLabel.setPreferredSize(tDimension);
      iDateOfBirthJTextField = new JTextField(15);
      // deal with the DateOfBirthBox
      final Box tDateOfBirthBox = new Box(BoxLayout.X_AXIS);
      tDateOfBirthBox.add(tDateOfBirthJLabel);
      tDateOfBirthBox.add(iDateOfBirthJTextField);
      // deal with the PhoneNumber
      final JLabel tPhoneNumberJLabel =
                        new JLabel("PhoneNumber", SwingConstants.RIGHT);
      tPhoneNumberJLabel.setPreferredSize(tDimension);
      iPhoneNumberJTextField = new JTextField(10);
      // deal with the Height
      final JLabel tHeightJLabel = new JLabel("Height", SwingConstants.RIGHT);
      tHeightJLabel.setPreferredSize(tDimension);
      iHeightJTextField = new JTextField(5);
      // deal with the ThirdRowBox
      final Box tThirdRowBox = new Box(BoxLayout.X_AXIS);
      tThirdRowBox.add(tPhoneNumberJLabel);
      tThirdRowBox.add(iPhoneNumberJTextField);
      tThirdRowBox.add(tHeightJLabel);
      tThirdRowBox.add(iHeightJTextField);
      // now create the form
      iBox = new Box(BoxLayout.Y_AXIS);
      iBox.add(tNameBox);
      iBox.add(tDateOfBirthBox);
      iBox.add(tThirdRowBox);
   } //BJCHERECONT
   public Component getGUI()
   {
      return iBox;
   }
   public Person getPerson()
   {
      return new PersonImpl(iNameJTextField.getText() +
                            "%" + iDateOfBirthJTextField.getText() +
                            "%" + iPhoneNumberJTextField.getText() +
                            "%" + iHeightJTextField.getText());
   }
   public void setPerson(final Person pPerson)
   {
      iNameJTextField.setText(pPerson.getName());
      iDateOfBirthJTextField.setText(pPerson.getDateOfBirth().toString());
      iPhoneNumberJTextField.setText(pPerson.getPhoneNumber());
      iHeightJTextField.setText("" + pPerson.getHeight());
   }
}
