/* * ============================================================= * BouncePanel.java : Bounce circles around on the screen. * Does not implement double buffering so has problems with * overlapping circles. Overrides update to avoid flickering * problems. * * Written by : Vasilios Lagakos March, 2001 * ============================================================== */ import javax.swing.*; import java.awt.*; import java.util.Vector; public class BouncePanel extends JComponent implements Runnable { private Vector circles; private int width, height; private Thread animationThread = null; boolean Reset = true; public BouncePanel() { circles = new Vector(); } //---------------------------------------------------- /*** Skip the usual screen-clearing step of update * so that there is no "flicker" between each * drawing step. */ public void update(Graphics g){ paint(g); } //---------------------------------------------------- /*** Erase each circle's old position, move it, * then draw it in new location. */ public void paint(Graphics g) { MovingCircle circle; width = getSize().width; height = getSize().height; for(int i=0; i