/* Run.java */ import java.awt.*; // needed for the graphics // import java.lang.Thread.*; class Run { public static void main(String[] argv) throws InterruptedException { // GridBagLayout layout = new GridBagLayout(); // Panel userPanel = new Panel(); FigureFrame frame = new FigureFrame(410,230); FigureCanvas canvas = new FigureCanvas(410,230); frame.add(canvas); System.out.println("Be patient, it takes a while ...."); // display some lines canvas.add(new HorizontalLine(10,10,380)); canvas.add(new HorizontalLine(10,190,380)); canvas.add(new VerticalLine(10,10,180)); canvas.add(new VerticalLine(390,10,180)); // Now add some figures to animate Figure [] figs = {new Triangle(158,110,10), new Triangle(152,110,10), new Square(65,150,20), new Square(115,150,20), new Square(150,120,30), new Rectangle(50,100,100,50)}; int i; // Add all the figures to the screen "canvas" to be displayed for (i = 0; i < figs.length; i++) { canvas.add(figs[i]); } frame.show(); // Now, animate as each figure in the vector for(int moves=0; moves < 40; moves++) { for(i=0; i < figs.length; i++) { figs[i].moveAndDraw(5,0,canvas.getGraphics()); } Thread.sleep(300); } System.out.println("Hit ^C to quit."); } }