Technical Support
Discussion Forum
Online Training
Read About Java
Java In-Depth
Product Discounts
Membership Information

Java Cup Logo

JDC Home Page


Working Applet
Help and Hints
Source Code
Table of Contents
Online Training
shadowSearchFAQFeedback

EMailTextField

Prerequisites

In this Exercise, you will subclass an existing compound component, LabeledTextField, to perform validation of the user entries upon an ACTION_EVENT or a LOST_FOCUS event (recall that FormElement will call verify upon these events). This will be used in our main RegistrationForm as a way to validate input on the client side.

Another example of creating your own components can be found in the PhoneTextField.

Perform the following tasks:

  1. Create an Applet to hold one instance of EMailTextField so you can test your component.
  2. Create class EMailTextField as a subclass of LabeledTextField. Make the constructor set the label to "E-Mail Address".
  3. Override the method verify of FormElement so that an error is printed if the text does not end with one of .com, .gov, .edu, .mil, .org, or .net. Also print an error if there is no @ symbol or it is the first character (there is no userid).

The task numbers above are linked to the step-by-step help page. Also available is a complete solution that meets these requirements.

Required by

Related Exercises