import java.io.*;
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.table.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;
import java.awt.geom.*;


public class  listP extends JPanel implements ListSelectionListener 
{
  JPanel inputPanel;
  JList<String> colorList;
  String colornames[]={"black","blue","cyan","dark gray","gray",
         "green","light grey","magenta","orange","pink","red","white","yellow"};
  Color colors[]={Color.black,Color.blue,Color.cyan,Color.darkGray,Color.gray,
	     Color.green,Color.lightGray,Color.magenta,Color.orange,Color.pink,
	     Color.red,Color.white,Color.yellow};
  
  public listP()
  {    
	colorList=new JList<String>(colornames);
	colorList.setVisibleRowCount(5);
    inputPanel=new JPanel();
    //inputPanel.add(new JScrollPane(colorList));
    inputPanel.add(colorList);
    add(inputPanel);
    colorList.addListSelectionListener(this);
  }


public void valueChanged( ListSelectionEvent e)
{
Color r1=colors[colorList.getSelectedIndex()];
inputPanel.setBackground(r1);
colorList.setBackground(r1);
setBackground(r1);
repaint();
}
}
