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

public class ThreeComboBoxes extends JApplet implements ItemListener
{
  FlowLayout flow = new FlowLayout();

  String[] Array1 = {"Small", "Big", "Huge"};
  String[] Array2 = {"Red", "Green", "Blue"};
  String[] Array3 = {"Balloons", "Balls", "Bears"};

  JComboBox ComboBox1 = new JComboBox(Array1);
  JComboBox ComboBox2 = new JComboBox(Array2);
  JComboBox ComboBox3 = new JComboBox(Array3);

  JLabel iSawThat = new JLabel("Small Red Balloons");

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

  public void itemStateChanged(ItemEvent event)
  {
    iSawThat.setText(ComboBox1.getSelectedItem() + " " + ComboBox2.getSelectedItem() + " " + ComboBox3.getSelectedItem());
    repaint();
  }
}
Hosted by www.Geocities.ws

1