CommentBox
Prerequisites
In this exercise, you will create a compound component
containing a Label and a TextArea. This will be used
in the main RegistrationForm
example as an input region for user comments.
Other examples of creating your own components can be found
in the JobTitleList
and LabeledChoice Exercises.
Perform the following tasks:
Create an Applet to hold one
instance of CommentBox so you can test the component.
Create class CommentBox as a subclass of FormElement.
In the class CommentBox, create a centered Label and a TextArea below it. Make the TextArea display three lines of 80 characters.
Implement the method isEmpty of FormElement to return true if the TextArea is empty.
Implement the method getContents of FormElement. It should return the Label and the contents of the CommentBox.
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
|