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

x
?
Solved

how to use light colour combination  in applet

Posted on 2001-06-14
4
Medium Priority
?
174 Views
Last Modified: 2010-03-31
Hi
I am working for games .
But through setBackground()and setForeground()method i am able to use only few main colours .
like
Color.black
Color.red
Color.yellow
Color.green
Color.pink
Color.orange
Color.magenta
Color.cyan
Color.gray
Could someone tell me suppose if i want to use except above colours like light colours or Olive,lightgreen,maroon ,purple,Naviblue then what i have to do ,how and what will be the coding for that .Because when i am trying to use maroon colour(setBackground(Color.maroon)its giving me the error "can't resolve symbol"


0
Comment
Question by:rkalpana
  • 2
4 Comments
 
LVL 92

Accepted Solution

by:
objects earned 40 total points
ID: 6190359
Have a look at the constructors for java.awt.Color. They enable you to specify the exact rbg combinations you require.
0
 
LVL 15

Expert Comment

by:ozymandias
ID: 6190367
The only colors you can refer to by name are :

black
blue
cyan
darkGray
gray
green
lightGray
magenta
orange
pink
red
white
yellow

Any other color you want to use you will have to create using the Color() constructors :

Color(ColorSpace cspace, float[] components, float alpha)
Color(float r, float g, float b)
Color(float r, float g, float b, float a)
Color(int rgb)
Color(int rgba, boolean hasalpha)
Color(int r, int g, int b)
Color(int r, int g, int b, int a)


0
 
LVL 92

Expert Comment

by:objects
ID: 6190379
And if rgb's aren't your thing (like most humans), here are the rbg's for color names:

http://eies.njit.edu/~kevin/rgb.txt.html
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 8950697


No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:


--  points to objects


Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
sudhakar_koundinya
EE Cleanup Volunteer
---------------------
If you feel that your question was not properly addressed, or that none of the comments received were appropriate answers, please post your concern in THIS thread.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

876 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