Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Color object  RSS feed

 
david allen
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Is it possible to create a color object based on the following color data.
#e0e0ff

The above code is defines a particular color or does the code have to consist of all integers ie. (255,143,223). I would like the user to enter the color via a similar code and to create a background color based on what they have entered.
Thank you for your help.
 
David Crossett
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By looking through the documentation, it doesn't look like it. I'm just *guessing*! Seems you'll have to translate the hex code somehow....
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All you'd have to do is remove the '#' from the front and pass it through Integer.parseInt( colorString, 16 ). Color has a constructor that will take the result of this and translate it to the appropriate color, so all you'll really have to do is :
 
Brian Pipa
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Color myColor = Color.decode("#e0e0ff");
Brian
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!