import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import javax.swing.event.*;  
public class exa9_16  extends JFrame implements ListSelectionListener{
	private JList list;
	private JLabel label;
	private String[] season = {"Spring", "Summer ", "Autumn", "Winter " };
	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_16() {
		super("б");
		this.setSize(200,200);
		this.getContentPane().setLayout(new FlowLayout());
		list = new JList(season);       	 	//б
	    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	    list.setVisibleRowCount(4);     	 	//ʹбʾ4
	  	list.setSelectedIndex(0);        		//ʼ״̬Ϊбĵһ
		list.addListSelectionListener(this);		//ע¼
		JScrollPane lsp = new JScrollPane(list);	//ӹ
		label=new JLabel(".gif");
		this.getContentPane().add(lsp);
		this.getContentPane().add(label);
			    this.setVisible(true);
	}
		public static void main(String args[])
		{	exa9_16 jl=new exa9_16 ();
		jl.addWindowListener(new WindowAdapter()
		{public void WindowClosing(WindowEvent e)
		{System.exit(0);
		}
		});
	}
	public void valueChanged(ListSelectionEvent e)
	{ label.setText(list.getSelectedValue().toString());
	 label.setIcon(icon[list.getSelectedIndex()]);   }
}
