/*
Remove Particular Item From AWT Choice Or Combobox Example
This java example shows how to remove a particular item of a choice or
a combobox control using remove method of AWT Choice class.
*/
import java.applet.Applet;
import java.awt.Choice;
/*
<applet code="RemoveItemExample" width=200 height=200>
</applet>
*/
public class RemoveItemExample extends Applet{
Choice language = null;
public void init(){
//create choice or combobox
language = new Choice();
//add items to the choice
language.add("Java");
language.add("C++");
language.add("VB");
language.add("Perl");
//add choice or combobox
add(language);
/*
* To remove an item from a choice or combobox, use
* void remove(int index) or
* void remove(String item) method of AWT Choice class.
*/
language.remove(1);
/*
* You can also use language.remove("C++")
*/
}
}
Example Output

Bookmark/Search this post with: