Write a graphics program that draws 12 strings, one each for the 12 standard colors, besides Color.WHITE, each in its own color. Provide a class ColorNameViewer and a class ColorNameComponent.

Here is a sample program output:

.

Complete the following file:

ColorNameComponent.java

import javax.swing.JComponent; import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; public class ColorNameComponent extends JComponent { public void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; . . . } }

Use the following file:

ColorNameViewer.java

import javax.swing.*;

/**
   Shows a frame with the standard color names.
*/
public class ColorNameViewer
{
   public static void main(String[] args)
   {
      JFrame frame = new JFrame();

      frame.setSize(300, 400);
      frame.setTitle("ColorNameViewer");
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

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

      frame.setVisible(true);
   }
}