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:

OlympicRingComponent.java

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 } }

Ring.java

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:

OlympicRingViewer.java

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);
      frame.setTitle("OlympicRingViewer");
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

      OlympicRingComponent component = new OlympicRingComponent();
      frame.add(component);

      frame.setVisible(true);
   }
}