Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to use hex to set background color?

 
achana chan
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
In my applet, I use the following line of code to set the foreground or background color:

Is there some way I could specify the hex value instead (simply because there are so many shades doing it with hex)?
TIA :-)
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Color.decode( String ) will take hex values as a string and return a color.
 
Brian Pipa
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use Color.decode() like so:
Color myColor = Color.decode("#6365ff");
Brian
 
Jason Steele
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
RGB is another option:
 
achana chan
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for taking time o look at my problem.
Both methods work for me now.
Is one way inherently more efficient ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic