Write a program that displays the Olympic rings. Color the rings in the Olympic colors. Provide a class OlympicRingViewer and a class OlympicRingComponent. Here is a sample program output:


Complete the following files:


import javax.swing.JComponent; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Color; /** Draws the olympic rings. */ public class OlympicRingComponent extends JComponent { public void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; // construct and draw five Ring objects } }


import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.geom.Ellipse2D; /** A class that draw the Olympic rings. */ public class Ring { ... /** Constructs a circle that represents the Olympic rings. @param anX the x coordinate @param aY the y coordinate @param aRadius the radius of the circle @param aColor the color of the ring */ public Ring(double anX, double aY, double aRadius, Color aColor) { ... } /** Draws the ring. @param g2 the graphic context */ public void draw(Graphics2D g2) { ... } }

Use the following file:


import javax.swing.*;

public class OlympicRingViewer
   public static void main(String[] args)
      JFrame frame = new JFrame();

      final int FRAME_WIDTH = 300;
      final int FRAME_HEIGHT = 230;

      frame.setSize(300, 230);

      OlympicRingComponent component = new OlympicRingComponent();