/*
Create Checked Checkbox Example
This java example shows how to create a checked Checkbox using AWT
Checkbox class.
*/
import java.applet.Applet;
import java.awt.Checkbox;
/*
<applet code="CreateCheckBox" width=200 height=200>
</applet>
*/
public class CreateCheckedCheckBox extends Applet{
public void init(){
//crete checkboxes
Checkbox checkBox1 = new Checkbox("My Checkbox 1");
/*
* To create a checked checkbox, use
* Checkbox(String label, boolean on)
* Constructor.
*/
Checkbox checkbox2 = new Checkbox("My Checkbox 2", true);
//add checkboxes using add method
add(checkBox1);
add(checkbox2);
}
}
Example Output

Bookmark/Search this post with: