Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 939
  • Last Modified:

Creating a Color Class?

I have to create a color class called Crayon that represents one crayon of a particular color and lenght/height..and design and implement a program that draws a box of crayons....I have the colors, but how to implement them as colors?

import java.awt.Color;
import javax.swing.JApplet;
import java.awt.*;


public class Crayon extends JApplet
{
   
    public void paint (Graphics page)
           
    {      
 int crayonShapeX[] = { 0, 2, 10, 15, 23, 25, 25, 0 };
 int crayonShapeY[] = { 15, 15, 0, 0, 15, 15, 45, 45 };

  private Color crayonColors[] = {
      Color.blue, Color.cyan, Color.darkGray,
      Color.gray, Color.green, Color.magenta,
      Color.orange, Color.pink, Color.red,
      Color.white, Color.yellow};

  }
}
0
April_Denise
Asked:
April_Denise
1 Solution
 
humanonomicsCommented:
Can you please re-phrase the question ? It is a bit confusing.
0
 
muktajindalCommented:
Use desired color by accessing array crayonColors[].
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now