Professional Documents
Culture Documents
*; /* <applet code="JComboBox1"width=250 height=150> </applet> */ public class JComboBox1 extends JApplet implements ItemListner { JTextField jtf; public void init() { Container ContentPane=getContentPane(); ContentPane.setLayout(new FlowLayout()); JComboBox jc=new JComboBox(); jc.addItem("Blue"); jc.addItem("Red"); jc.addItemListner(this); ContentPane.add(jtf); } public void ItemStateChanged(ItemEvent ie) { String s=(String)ie.getItem(); jtf.setText("Selected color"+s); } }