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

public class ComboBox extends JApplet implements ItemListener
{
  FlowLayout flow = new FlowLayout();
  String[] anArray = {"Nothing", "One", "Two", "Three"};
  JComboBox aComboBox = new JComboBox(anArray);
  JLabel iSawThat = new JLabel("Nothing was clicked.");

  public void init()
  {
    Container con = getContentPane();
    con.setLayout(flow);
    con.add(aComboBox);
    con.add(iSawThat);
    
    aComboBox.addItemListener(this);
  }

  public void itemStateChanged(ItemEvent event)
  {
    iSawThat.setText(aComboBox.getSelectedItem() + " was clicked.");
    repaint();
  }
}
Hosted by www.Geocities.ws

1