• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 199
  • Last Modified:

color

I want to find out the RGB values for a string value
for example i want to find the RGB values for "Azure"
or in other hand i want to find the hexvalue of that color ,no difference
How can i do that ?
0
ta2000
Asked:
ta2000
1 Solution
 
harvkCommented:
I don't understand exactly what you want to do, but take a look at the static decode() method of the awt.Color class. Once you got the Color, you can extract the RGB values with the respective methods.

0
 
ta2000Author Commented:
let me explain it in more details
I have a list which it contains  color names (such as blue,azure, cyan,LightSeaGreen, LemonChiffon and so on)
Now i want when i choose a color in my list i want to  view the hexvalue of that specified color.
for using decode i have to give the hexvalue of the color as argument .so i cant use it here,
thanks
0
 
ta2000Author Commented:
could someone help me .i am in a rush
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
membershCommented:
Use getBlue(), getGreen() & getRed() of Color to get integer values for the given Color. Use toHexString(int i) of Interger class to get hex for that int. Depending on ur requirement, u can concat it & display or whatever...
0
 
ta2000Author Commented:
can you give a line of example coz i tried it but it didnt give the answer maybe my code was wrong
0
 
CEHJCommented:
You can only get the constituents of colors that have named constants. For instance, there is no 'LightSeaGreen'.

For named constants:

String r = "0x" + Integer.toHexString(Color.pink.getRed());
String g = "0x" + Integer.toHexString(Color.pink.getGreen());
String b = "0x" + Integer.toHexString(Color.pink.getBlue());
0
 
ta2000Author Commented:
hi
I was looking for all the colors not only constants
thanks
0
 
CEHJCommented:
Only a few of them have 'names'.
0
 
CleanupPingCommented:
ta2000:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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