Article View: borland.public.jbuilder.java.language
Article #697Re: Color to Hex string
From: John McGrath [TeamB]
Date: Wed, 01 Dec 2004 06:41
Date: Wed, 01 Dec 2004 06:41
29 lines
1764 bytes
1764 bytes
On 11/30/2004 at 3:02:24 PM, Alan Shiers wrote:
> Does anyone have a class method that takes a java.awt.Color object as a
> parameter and returns a hexadecimal String of the form: "#FFAD00" ?
>
> Somethink like this:
>
> public String convertColorToHexString(java.awt.Color c)
> {
> ...
> }
I do not know of one that exists already, but it is not very hard to write
one:
public String convertColorToHexString(java.awt.Color c)
{
String str = Integer.toHexString( c.getRGB() & 0xFFFFFF );
return ( "#" + "000000".substring( str.length() ) + str.toUpperCase() );
}
--
Regards,
John McGrath [TeamB]
---------------------------------------------------
Before sending me e-mail, please read:
http://www.JPMcGrath.net/newsgroups/e-mail.html
Technical Details
Message-ID:
<xn0dqhf5t1hnd2f006@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!lnewsoutpeer01.lnd.ops.eu.uu.net!lnewsinpeer01.lnd.ops.eu.uu.net!emea.uu.net!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<41acd295$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: f74b3,77c23dd879f84904 X-Google-Attributes: gidf74b3,public X-Google-Language: ENGLISH,ASCII-7-bit From: "John McGrath [TeamB]" <ng-b@JPMcGrath.net> Subject: Re: Color to Hex string Newsgroups: borland.public.jbuilder.java.language References: <41acd295$1@newsgroups.borland.com> User-Agent: XanaNews/1.16.5.2 Message-ID: <xn0dqhf5t1hnd2f006@newsgroups.borland.com> X-Ref: newsgroups.borland.com ~XNS:0000008B MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 NNTP-Posting-Host: 151.197.30.130 Date: 30 Nov 2004 23:41:30 -0700 X-Trace: newsgroups.borland.com 1101886890 151.197.30.130 (30 Nov 2004 23:41:30 -0700) Lines: 29 X-Authenticated-User: jpmcgrath Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!lnewsoutpeer01.lnd.ops.eu.uu.net!lnewsinpeer01.lnd.ops.eu.uu.net!emea.uu.net!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail