This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Java in General and the fly likes how to apply hex value to color class Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "how to apply hex value to color class" Watch "how to apply hex value to color class" New topic
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to apply hex value to color class
 
Similar Threads
Conversion
How to convert a number to Hexadecimal or Octal format..
Calling a Hashtable from another class.
Ascii to Hex
dynamic color