import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import javax.swing.event.*;
public class exa9_17  extends JFrame implements ItemListener{
	private JComboBox cbb;
	private JLabel label;
	private ImageIcon i1=new ImageIcon("p1.gif");
	private ImageIcon i2=new ImageIcon("p2.gif");
	private ImageIcon i3=new ImageIcon("p3.gif");
	private ImageIcon i4=new ImageIcon("p4.gif"); 
	private Icon icon[]={i1,i2,i3,i4};       	//ͼ
	public  exa9_17() {
		super("һļ");
		this.setLocation(100,100);
		this.getContentPane().setLayout(new FlowLayout());
		cbb = new JComboBox();        	//б
		cbb.addItem("");
		cbb.addItem("");
		cbb.addItem("");
		cbb.addItem("");
		cbb.addItemListener(this); 			//ע¼
		label=new JLabel("ͼƬ");
		this.getContentPane().add(cbb);
		this.getContentPane().add(label);
		this.pack();
		this.setVisible(true);
	}
	public static void main(String args[]){
	exa9_17  jc=new exa9_17();
	jc.addWindowListener(new WindowAdapter()
	{public void WindowClosing(WindowEvent e)
	{System.exit(0);
	}
	});
}
//¼
	public void itemStateChanged(ItemEvent e)
	{	label.setIcon(icon[cbb.getSelectedIndex()]);
	}
}
