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

Bookmark/Search this post with: