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  listP1  extends JPanel implements ListSelectionListener 
{
  shapeP shape;
  JPanel inputPanel;
  JPanel outputPanel;
  JList<String> shapelist;
  JList<String> colorlist;
  String shapenames[]={"filled star","filled ellipse"};
  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 listP1()
  {    
	int i=0;
	shape=new shapeP(Color.black,i);
	colorlist=new JList<String>(colornames);
	colorlist.setVisibleRowCount(5);
	shapelist=new JList<String>(shapenames);
    inputPanel=new JPanel();
    inputPanel.setBackground(Color.YELLOW);
    inputPanel.setLayout(new BorderLayout());
    this.setLayout(new BorderLayout());
    outputPanel=new JPanel();
    outputPanel.setLayout(new BorderLayout());
    outputPanel.add(shape,BorderLayout.CENTER);
    inputPanel.add(new JScrollPane(colorlist),BorderLayout.EAST);
    inputPanel.add(new JScrollPane(shapelist),BorderLayout.WEST);
    outputPanel.add(shape,BorderLayout.CENTER);
    add(inputPanel,BorderLayout.NORTH);
    add(outputPanel,BorderLayout.CENTER);
    colorlist.addListSelectionListener(this);
    shapelist.addListSelectionListener(this);
  }

public void valueChanged( ListSelectionEvent e)
{
if(e.getSource()==colorlist)
{
Color r1=colors[colorlist.getSelectedIndex()];
shape.setColor(r1);
}
if(e.getSource()==shapelist)
{shape.setShape(shapelist.getSelectedIndex());}
repaint();
}


}
