import javax.swing.*;

/**
 * A demonstration of a simple ListCellRenderer.
 * 
 * @author Prof. David Bernstein, James Madison University
 * @version 1.0
 */
public class FractionCellRendererDemo 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 FractionCellRendererDemo());
  }
  
 /**
  * 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();

    Fraction[] fractions = {new Fraction(1,2), new Fraction(3,4), new Fraction(13,16)};
    JList<Fraction> list = new JList<Fraction>(fractions);
    list.setCellRenderer(new FractionCellRenderer());
    
    contentPane.add(list);
    f.setVisible(true);
  }
}
