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