This week's book giveaway is in the
General Computing
forum.
We're giving away four copies of
Arduino in Action
and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See
this thread
for details.
A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
Arduino in Action
this week in the
General Computing
forum!
A special promo:
Enter your blog post or vote on a blogger to be featured in an upcoming Journal
JavaRanch
»
Java Forums
»
Java
»
Swing / AWT / SWT
Author
how to use hex to set background color?
achana chan
Ranch Hand
Joined: Jul 29, 2002
Posts: 277
posted
Feb 02, 2004 02:21:00
0
Hi.
In my
applet
, I use the following line of code to set the foreground or background color:
aKomponent.setBackground(Color.YELLOW); someKomponet.setBorder(BorderFactory.createLineBorder(Color.ORANGE));
Is there some way I could specify the hex value instead (simply because there are so many shades doing it with hex)?
TIA :-)
humanum errare est.
Nathan Pruett
Bartender
Joined: Oct 18, 2000
Posts: 4121
I like...
posted
Feb 02, 2004 07:21:00
0
Color.decode(
String
) will take hex values as a string and return a color.
-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Brian Pipa
Ranch Hand
Joined: Sep 29, 2003
Posts: 299
posted
Feb 02, 2004 07:24:00
0
Use Color.decode() like so:
Color myColor = Color.decode("#6365ff");
Brian
My Java Freeware:<br />MACCC - <a href="http://maccc.pipasoft.com" target="_blank" rel="nofollow">http://maccc.pipasoft.com</a><br />Nator - <a href="http://nator.pipasoft.com" target="_blank" rel="nofollow">http://nator.pipasoft.com</a>
Jason Steele
Ranch Hand
Joined: Apr 25, 2003
Posts: 100
posted
Feb 02, 2004 11:22:00
0
RGB is another option:
Color redColor = new Color(255,0,0);
An egg is a chicken's house!
achana chan
Ranch Hand
Joined: Jul 29, 2002
Posts: 277
posted
Feb 04, 2004 00:52:00
0
Thank you for taking time o look at my problem.
Both methods work for me now.
Is one way inherently more efficient ?
I agree. Here's the link:
http://zeroturnaround.com/jrebel
- it saves me about five hours per week
subject: how to use hex to set background color?
Similar Threads
Color table.
new image after rotate
how to use rgb color values to set JPanel background color
new image after rotate
HTML Horizontal Line
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter