You are on page 1of 1

import java.awt.*; import java.awt.event.*; import javax.swing.

*; /* <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); } }

You might also like