Create AWT Radio Buttons Using CheckboxGroup Example
- /*
- Create AWT Radio Buttons Using CheckboxGroup Example
- This java example shows how to create radio buttons using AWT CheckboxGroup
- class.
- */
- import java.applet.Applet;
- import java.awt.Checkbox;
- import java.awt.CheckboxGroup;
- /*
- <applet code="CreateRadioButtonsExample" width=200 height=200>
- </applet>
- */
- public class CreateRadioButtonsExample extends Applet{
- public void init(){
- /*
- * To create a checkbox group, use
- * CheckboxGroup()
- * constructor of AWT CheckboxGroup class.
- */
- CheckboxGroup lngGrp = new CheckboxGroup();
- //if you create checkboxes and add to group,they become radio buttons
- Checkbox java = new Checkbox("Java", lngGrp, true);
- Checkbox cpp = new Checkbox("C++", lngGrp, true);
- Checkbox vb = new Checkbox("VB", lngGrp, true);
- //add radio buttons
- add(java);
- add(cpp);
- add(vb);
- }
- }
Example Output




