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 40 41 42 43 44 45 46 |
/* Create AWT Checkbox Example This java example shows how to create a Checkbox using AWT Checkbox class. */ import java.applet.Applet; import java.awt.Checkbox; /* <applet code="CreateCheckBox" width=200 height=200> </applet> */ public class CreateCheckBox extends Applet{ public void init(){ /* * To create a checkbox use * Checkbox() constructor. */ Checkbox checkBox1 = new Checkbox(); /* * Set Checkbox caption or label using * void setLabel(String text) * method of AWT Checkbox class. */ checkBox1.setLabel("My Checkbox 1"); /* * To create checkbox with the caption use * CheckBox(String text) constructor of * AWT Checkbox class. */ Checkbox checkbox2 = new Checkbox("My Checkbox 2"); //add checkboxes using add method add(checkBox1); add(checkbox2); } } |
Example Output
Add Comment