Help: Radio buttons


Help is available for each task, or you can go straight to the solution source code.

Task 1

Create a new applet called RadioButtons and add a two checkboxes called C++ Programmers and Procedural Programmers or whatever you'd like. Link them to a CheckboxGroup.

Note that although the checkboxes appear not to be RadioButtons, when you run the applet they'll display properly if they're linked through a CheckBoxGroup bean.


The CheckboxGroup bean must be dropped outside the applet frame.

Connect the CheckboxGroup's this property to both of the Checkbox's checkboxGroup property.

Task 2

Now add a textfield to the applet such that when a given RadioButton is activated, the contents of the TextField show the RadioButton's label.

For each label, do the following:

  1. Left click on the label and select: Connect->All features and in the dialog select MouseClicked(java.awt.Event) and hit OK Now make this connection to the TextField's text method.

    Note that the connection is marked with a dashed green line. You will complete the connection in the next step.

  2. Connect the label's label property to the value property of the connection you established in the step above. Note that a small circle will appear when you've moved the mouse over the correct part of the destination connection.

Copyright © 1996-1997 MageLang Institute. All Rights Reserved.