import java.awt.*;
import javax.swing.*;

/**
 * A demonstration of a simple ListCellRenderer.
 * 
 * @author Prof. David Bernstein, James Madison University
 * @version 1.0
 */
public class ColorCellRendererDemo 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 ColorCellRendererDemo());
  }
  
 /**
  * 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();

    Color[] colors = {Color.RED, Color.GREEN, Color.BLUE};
    JList<Color> list = new JList<Color>(colors);
    list.setCellRenderer(new ColorCellRenderer());
    
    contentPane.add(list);
    f.setVisible(true);
  }
}
