/*
Remove AWT Checkbox From Applet or Window Frame Example
This java example shows how to remove a Checkbox from window frame or an applet.
*/
import java.applet.Applet;
import java.awt.Checkbox;
/*
<applet code="RemoveCheckboxExample" width=200 height=200>
</applet>
*/
public class RemoveCheckboxExample extends Applet{
public void init(){
//create Checkboxes
Checkbox Checkbox1 = new Checkbox("Checkbox 1");
Checkbox Checkbox2 = new Checkbox("Checkbox 2");
//add Checkboxes
add(Checkbox1);
add(Checkbox2);
/*
* To remove a Checkbox from window, use
* void remove(Component c)
* method.
*
* Remove method removes the specified component from the
* container.
*/
remove(Checkbox1);
}
}
Example Output

Bookmark/Search this post with: