Complete the following files:

RandomCircleComponent.java

import javax.swing.JComponent; import java.awt.Graphics; import java.awt.Graphics2D; import java.util.Random; /** A RandomCircleComponent draws a number of random circles. */ public class RandomCircleComponent extends JComponent { . . . /** Constructs a RandomCircleComponent that draws a given number of circles. @param n the number of circles to draw. */ public RandomCircleComponent(int n) { . . . } public void paintComponent(Graphics g) { . . . } }

RandomCircleViewer.java

Use the following file:

RandomCircleViewerSnap.java

import javax.swing.JFrame;

/**
   Snap driver class for RandomCircleComponent class.
*/
public class RandomCircleViewerSnap
{
   public static void main(String[] args)
   {
      JFrame frame = new JFrame();

      final int FRAME_WIDTH = 400;
      final int FRAME_HEIGHT = 400;

      frame.setSize(FRAME_WIDTH, FRAME_HEIGHT);
      frame.setTitle("RandomCircleViewer");
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

      RandomCircleComponent component = new RandomCircleComponent(10);
      frame.add(component);

      frame.setVisible(true);
   }
}