| Author |
how to apply hex value to color class
|
swapnel surade
Ranch Hand
Joined: Mar 05, 2009
Posts: 129
|
|
Hi,
I have a color value as #555656. I want to apply this value to java.awt.Color class.
This class accepts the value from 0 to 255...
how to convert this hex value to specified value for Color class ?
thanks
|
 |
Maneesh Godbole
Saloon Keeper
Joined: Jul 26, 2007
Posts: 8435
|
|
|
Did you check the API? Did you find anything which would decode a hexadecimal string and return the Color?
|
[Donate a pint, save a life!] [How to ask questions] [Onff-turn it on!]
|
 |
swapnel surade
Ranch Hand
Joined: Mar 05, 2009
Posts: 129
|
|
|
Interger.parseInt(str,int) do that.... but the problem is, value returned from this method applicable for color class
|
 |
Maneesh Godbole
Saloon Keeper
Joined: Jul 26, 2007
Posts: 8435
|
|
My bad.
I meant the API for the Color class
|
 |
swapnel surade
Ranch Hand
Joined: Mar 05, 2009
Posts: 129
|
|
I have converted the hex to int and it worked for me...
|
 |
Maneesh Godbole
Saloon Keeper
Joined: Jul 26, 2007
Posts: 8435
|
|
swapnel surade wrote:I have converted the hex to int and it worked for me...
Too bad.
You could have used
From the API docs
Converts a String to an integer and returns the specified opaque Color. This method handles string formats that are used to represent octal and hexidecimal numbers.
|
 |
 |
|
|
subject: how to apply hex value to color class
|
|
|