Your task is to draw the lamps in a traffic light.

Here is a sample program output:


Complete the following file:

import javax.swing.JComponent; import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.geom.Ellipse2D; public class TrafficLightComponent extends JComponent { public void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; // your work here . . . } }

Use the following file:

import javax.swing.*;

   Shows a frame with a traffic light
public class TrafficLightViewer
   public static void main(String[] args)
      JFrame frame = new JFrame();
      frame.setSize(300, 400);
      TrafficLightComponent component = new TrafficLightComponent();