Sun Java Solaris Communities My SDN Account Join SDN
 
Tutorials & Code Camps

Radio Buttons

 

Training Index

by jGuru

Help  API Docs  About This Short Course  Short Course  Exercises

Create an applet RadioButtons with two radio buttons that allow a user to choose between two opinions of the Java programming language.

Skeleton Code

Tasks

1. Create a Panel instance and add three components to it:
  1. The label "Java is:"
  2. A checkbox labeled "Powerful"
  3. A checkbox labeled "Elegant"

The two Checkbox objects should be under the control of a CheckboxGroup object.

Add the panel to the applet.

2. Register and listen for events in the RadioButtons applet in order to display the label of the activated checkbox in the TextField object (already provided). (RadioButtons should implement the ItemListener interface.)

Where help exists, the task numbers above are linked to the step-by-step help page.

Solution Source

Demonstration

This exercise only runs within browsers that support the Java Runtime Environment 1.1 and appletviewer. If you are using an appropriate browser, try this exercise. The output should look similar to the following:

RADIO.GIF

Next Exercise

Exercises

Short Course

Copyright 1996-2000 jGuru.com. All Rights Reserved.