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 |
/* Select Particular Item Of AWT Choice Or Combobox Example This java example shows how to select a particular item of a choice or a combobox control using select method of AWT Choice class. */ import java.applet.Applet; import java.awt.Choice; /* <applet code="SelectItemExample" width=200 height=200> </applet> */ public class SelectItemExample 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 select an item from a choice or combobox, use * void select(int index) or * void select(String item) method of AWT Choice class. */ language.select(1); /* * You can also use language.select("C++") */ } } |
Example Output
Add Comment