1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
/* 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
Thank you 🙂
Thanks this example helps in my exam