    01: import java.awt.*;
    02: import javax.swing.*;
    03:
    04: /**
    05:    This program animates a sort algorithm.
    06: */
    07: public class AnimationTest
    08: {
    09:    public static void main(String[] args)
    10:    {
    11:       JFrame frame = new JFrame();
    12:       frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    13:
    14:       Container contentPane = frame.getContentPane();
    15:       ArrayPanel panel = new ArrayPanel();
    16:       contentPane.add(panel, BorderLayout.CENTER);
    17:
    18:       frame.setSize(FRAME_WIDTH, FRAME_HEIGHT);
    19:       frame.show();
    20:
    21:       Object[] values = new Object[VALUES_LENGTH];
    22:       for (int i = 0; i < values.length; i++)
    23:          values[i] = new Integer(
    24:             (int)(Math.random() * panel.getHeight()));
    25:
    26:       Runnable r = new Sorter(values, panel);
    27:       Thread t = new Thread(r);
    28:       t.start();
    29:    }
    30:
    31:    private static final int VALUES_LENGTH = 30;
    32:    private static final int FRAME_WIDTH = 300;
    33:    private static final int FRAME_HEIGHT = 300;
    34: }