001package horstmann.ch09_animation1;
002import java.awt.BorderLayout;
003
004import javax.swing.JFrame;
005
006/**
007   This program animates a sort algorithm.
008 */
009public class AnimationTester
010{
011        public static void main(String[] args)
012        {
013                JFrame frame = new JFrame();
014                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
015
016                ArrayComponent panel = new ArrayComponent();
017                frame.add(panel, BorderLayout.CENTER);
018
019                frame.setSize(FRAME_WIDTH, FRAME_HEIGHT);
020                frame.setVisible(true);
021
022                Double[] values = new Double[VALUES_LENGTH];
023                for (int i = 0; i < values.length; i++)
024                        values[i] = Math.random() * panel.getHeight();
025
026                Runnable r = new Sorter(values, panel);
027                Thread t = new Thread(r);
028                t.start();
029        }
030
031        private static final int VALUES_LENGTH = 30;
032        private static final int FRAME_WIDTH = 300;
033        private static final int FRAME_HEIGHT = 300;
034}