import java.awt.*;
import java.awt.geom.*;
import javax.swing.*;

/**
 * A demonstration of a simple ListCellRenderer.
 * 
 * @author Prof. David Bernstein, James Madison University
 * @version 1.0
 */
public class ShapeCellRendererDemo implements Runnable
{
  /**
   * Create the GUI.
   * 
   * @param args The command line arguments (which are ignored)
   * @throws Exception if something goes wrong
   */
  public static void main(String[] args) throws Exception
  {
    SwingUtilities.invokeAndWait(new ShapeCellRendererDemo());
  }
  
  /**
   * The code to execute in the event dispatch thread.
   */
  public void run()
  {
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setSize(640,  480);
    
    JPanel contentPane = (JPanel)f.getContentPane();

    Shape[] shapes = {new Rectangle2D.Double(10,10,50,50), new Ellipse2D.Double(10, 10, 50, 50),
        new Arc2D.Double(10, 10, 50, 50, 0., 270., Arc2D.PIE)};
    
    JList<Shape> list = new JList<Shape>(shapes);
    list.setCellRenderer(new ShapeCellRenderer());
    
    contentPane.add(list);
    f.setVisible(true);
  }
}
