Article View: borland.public.jbuilder.java.language
Article #699Re: Color to Hex string
From: John McGrath [TeamB]
Date: Wed, 01 Dec 2004 16:53
Date: Wed, 01 Dec 2004 16:53
25 lines
2019 bytes
2019 bytes
On 12/1/2004 at 8:30:12 AM, Alan Shiers wrote:
> Just curious about one thing though, John. On the second line you write:
>
> "000000".substring( str.length() )
>
> Why is this necessary? I wrote out a println statement:
> System.out.println("substring = " + "000000".substring( str.length() ));
> And all this does is return an empty string. Why concatonate with an
> empty string? Is there some reason for this?
It is only an empty string if Integer.toHexString() returns a 6 character
string. If you feed it Color.BLACK, it will return the String "0", in
which case str.length() will be 1, so substring wil return "00000". So
this code just zero-fills the hex number to 6 digits. If the string "#0"
is acceptable, you can eliminate that part.
--
Regards,
John McGrath [TeamB]
---------------------------------------------------
Before sending me e-mail, please read:
http://www.JPMcGrath.net/newsgroups/e-mail.html
Technical Details
Message-ID:
<xn0dqhv9r23j0pt008@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news-in.ntli.net!newsrout1-win.ntli.net!ntli.net!colt.net!easynet-monga!easynet.net!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<41acd295$1@newsgroups.borland.com> <xn0dqhf5t1hnd2f006@newsgroups.borland.com> <41adc82f$3@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> <xn0dqhf5t1hnd2f006@newsgroups.borland.com> <41adc82f$3@newsgroups.borland.com> User-Agent: XanaNews/1.16.5.2 Message-ID: <xn0dqhv9r23j0pt008@newsgroups.borland.com> X-Ref: newsgroups.borland.com ~XNS:0000008D MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 NNTP-Posting-Host: 141.158.60.123 Date: 1 Dec 2004 09:53:46 -0700 X-Trace: newsgroups.borland.com 1101923626 141.158.60.123 (1 Dec 2004 09:53:46 -0700) Lines: 25 X-Authenticated-User: jpmcgrath Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news-in.ntli.net!newsrout1-win.ntli.net!ntli.net!colt.net!easynet-monga!easynet.net!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail