import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class DavidApplet extends
Applet implements ActionListener
{
//Declaring Variables
String firstName;
String lastName;
String address;
String city;
String state;
String zip;
String arrivalDate;
int numberNights;
//Create components for the applet
Label firstNameLabel = new Label("First Name:");
TextField firstNameField = new TextField(15);
Label lastNameLabel = new Label("LastName:");
TextField lastNameField = new TextField(15);
Label addressLabel = new Label("Address:");
TextField addressField = new TextField(15);
Label cityLabel = new Label(" City:");
TextField cityField = new TextField(15);
Label stateLabel = new Label(" State:");
TextField stateField = new TextField(15);
Label zipLabel = new Label("Zip:");
TextField zipField = new TextField(15);
Label campingVehiclesLabel = new Label(" ");
Choice campingVehiclesChoice = new Choice();
Label hookUpLabel = new Label(" ");
Choice hookUpChoice = new Choice();
Label arrivalDateLabel = new Label(" Arrival Date");
TextField arrivalDateField = new TextField(15);
Label numberNightsLabel = new Label(" Number of Nights");
TextField numberNightsField = new TextField(15);
Button submitButton = new Button("Submit ");
Button clearButton = new Button("Clear");
public void init()
{
//Add components to window and set colors
setBackground(Color.orange);
add(firstNameLabel);
add(firstNameField);
firstNameField.requestFocus();
add(lastNameLabel);
add(lastNameField);
add(addressLabel);
add(addressField);
add(cityLabel);
add(cityField);
add(stateLabel);
add(stateField);
add(zipLabel);
add(zipField);
add(campingVehiclesLabel);
add(campingVehiclesChoice);
campingVehiclesChoice.addItem("Camping Vehicles");
campingVehiclesChoice.addItem("Tent ");
campingVehiclesChoice.addItem("Pop-up ");
campingVehiclesChoice.addItem("Travel Trailer ");
campingVehiclesChoice.addItem("Fifth-Wheel ");
campingVehiclesChoice.addItem("Motor Home ");
add(hookUpLabel);
add(hookUpChoice);
hookUpChoice.addItem("Hook-ups ");
hookUpChoice.addItem("Water only ");
hookUpChoice.addItem("Water and Electricity");
hookUpChoice.addItem("Full Hook-ups ");
hookUpChoice.addItem("No Hook-up ");
add(numberNightsLabel);
add(numberNightsField);
add(arrivalDateLabel);
add(arrivalDateField);
add(submitButton);
submitButton.addActionListener(this);
add(clearButton);
clearButton.addActionListener(this);
}
public void actionPerformed(ActionEvent e)
{
String arg = e.getActionCommand();
if (arg == "Submit")
{
//Assigning data
firstName = firstNameField.getText();
lastName = lastNameField.getText();
address = addressField.getText();
city = cityField.getText();
state = stateField.getText();
zip = zipField.getText();
arrivalDate = arrivalDateField.getText();
numberNights = Integer.parseInt(numberNightsField.getText());
}
if (arg == "Clear")
{
firstNameField.setText("");
lastNameField.setText("");
addressField.setText("");
cityField.setText("");
stateField.setText("");
zipField.setText("");
arrivalDateField.setText("");
numberNightsField.setText("");
repaint();
}
}
}