|
|
|
|
|
|
Creating a Registration Form Applet
This Exercise teaches you how to build an applet called RegistrationForm that acts as a registration form for Java courses. This applet will validate some of the fields and the collected information will be printed to System.out, but only if all fields are nonempty and valid. Check the expected behavior for this Exercise. Your RegistrationForm should ask prospective students to select a course, provide contact information (name, phone, email), provide payment choice, specify job title, and give any comments they may have. A Submit button should be used to collect the information (here, you will only dump it to System.out, but a real applet would email the information or connect to a server). The phone number and email address should be verified for correctness. This functionality is described in FormElement, PhoneTextField, and EMailTextField. This Exercise is composed of several compound components, that you will develop in the process of completing the subexercises:
Only ContactInfoForm and CommentBox are directly referenced by this applet. These Exercises will direct you to the others listed above. The following diagram illustrates the class hierarchy for all input elements of RegistrationForm:
FormElement is the superclass of all input elements and defines their basic behavior. In addition to form input elements, you will have a title label ("Course Registration") and a Submit button. The following diagram illustrates the "containment hierarchy" for RegistrationForm:
where LabeledTextField contains:
PhoneTextField contains:
EMailTextField contains:
and LabeledChoice contains:
The layout of your applet should mimic that of the expected behavior provided for you. It is suggested that you follow the containment hierarchy and class naming convention so that help information corresponds more closely to your emerging applet.
In order to complete this Exercise, you must perform the following tasks:
which are all derived from FormElement. You will want to set the layout manager for mainPanel so that it lays out the compound components per the expected behavior. In the method init, create a "Course Registration" Label with "Dialog," in an 18-point bold font. Create a "Submit" Button. In the method init, add the "Course Registration" title, mainPanel, and Submit Button to RegistrationForm applet such that they are laid out according to the expected behavior. In the method action (which will be called when the Submit Button is pushed), if the course selection, contact information, and job title are all nonempty, dump the contents to System.out. See FormElement to learn how the form elements can be queried. |