Solved

Creating a Color Class?

Posted on 2008-10-30
2
931 Views
Last Modified: 2013-11-23
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
Comment
Question by:April_Denise
2 Comments
 
LVL 7

Accepted Solution

by:
humanonomics earned 125 total points
ID: 22847852
Can you please re-phrase the question ? It is a bit confusing.
0
 
LVL 5

Expert Comment

by:muktajindal
ID: 22848142
Use desired color by accessing array crayonColors[].
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
DO we need Java installed on a Windows PC and WHY ? 13 94
Java Timer (static) 9 36
windows explorer path to command prompt 5 27
java jdbc batch example 8 17
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

943 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now