import java.util.*; import javax.swing.*; import java.awt.*; /** * A Box has a visible appearance on screen as a square, white area. * A Box can contain a number of Balls, that can be moved around. */ class Box extends JComponent{ private static final int MAXBALLS = 100; private static final int WIDTH = 400; private static final int HEIGHT= 400; private Ball [] theBalls; private int ballCount = 0; private Color color = Color.WHITE; /** * Create an empty Box and render it on screen. */ public Box(){ theBalls = new Ball[100]; setPreferredSize(new Dimension(WIDTH,HEIGHT)); } /** * Add a ball to this Box. */ public void addBall(Ball b){ theBalls[ballCount] = b; ballCount++; } /** * Let each ball in the box do n steps, with * delay d milliseconds between each step. */ public void moveAllBalls(int n, int d) { for(int k=0; k