import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class Exam5_7 extends java.applet.Applet implements ItemListener,ActionListener
{
CheckboxGroup cb;
Checkbox red,yellow,green,blue;
List ls;
Color co=red;
public void init()
{
cb=new CheckboxGroup();
red=new Checkbox( "红色 ",cb,true);
red.addItemListener(this);
add(red);
yellow=new Checkbox( "黄色 ",cb,false);
yellow.addItemListener(this);
add(yellow);
green=new Checkbox( "绿色 ",cb,false);
green.addItemListener(this);
add(green);
blue=new Checkbox( "蓝色 ",cb,false);
blue.addItemListener(this);
add(blue);
ls=new List(5);
ls.add( "绿色 ",1);
ls.add( "蓝色 ",2);
ls.add( "橙色 ",3);
ls.add( "黑色 ",4);
ls.add( "粉色 ",5);
ls.addItemListener(this);
add(ls);
}
public void itemStateChanged(ItemEvent e)
{
if(e.getSource()== "红色 ") co=Color.red;
if(e.getSource()== "黄色 ") co=Color.yellow;
if(e.getSource()== "绿色 ") co=Color.green;
if(e.getSource()== "蓝色 ") co=Color.blue;
ShowStatus(lc.getSelectedItem()+ "顺序号 "+lc.getSelectedIndex());
repaint();
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()== "红色 ") co=Color.red;
if(e.getSource()== "蓝色 ") co=Color.blue;
if(e.getSource()== "橙色 ") co=Color.cyan;
if(e.getSource()== "黑色 ") co=Color.black;
if(e.getSource()== "粉色 ") co=Color.DARK_GRAY;
showStatus(lc.getSelectedItem()+ " "+lc.getSelectedIndex());
repaint();
}
public void paint(Graphics g)