import java.awt.*; // Graphics stuff import java.awt.event.*; // ActionListener and Timer import javax.swing.*; // JFrame, JPanel import java.util.Random; // Random number generator used by each BouncingBall public class BouncingBalls { public static void main(String[] args) { JFrame frame=new JFrame(); frame.setSize(540,540); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); GraphicsPanel gp=new GraphicsPanel(); frame.add(gp); frame.setVisible(true); } public static class GraphicsPanel extends JPanel implements ActionListener // here is where the action is { private BouncingBall[] balls; // We will create an array of BouncingBalls to move around the screen private int number; // this stores the number of BouncingBalls to deal with, change this value to increase or decrease number of balls on the screen private Random generator; // used to initialize ball location, motion and color public GraphicsPanel() { number=25; // we'll use 25 generator=new Random(); balls=new BouncingBall[number]; // instantiate the array for(int i=0;i