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

RadioButtons

Prerequisites

In this Exercise, you will create a compound component containing a Label and two Checkbox components grouped together to act as radio buttons. This will be used in the main RegistrationForm to allow the user to choose between two different Java courses.

Other examples of creating your own components can be found in the JobTitleList and CommentBox Exercises.

Perform the following tasks:

  1. Create an Applet to hold one instance of RadioButtons so you can test your component.
  2. Create the class RadioButtons as a subclass of FormElement.
  3. In class RadioButtons, create a left-justified Label ("Java for: ") and two Checkbox objects ("C++ Programmers" and "Procedural Programmers") to the right, controlled by a CheckboxGroup.
  4. Implement method getContents of FormElement. It should return the Label and the text of the selected course.
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