Article View: borland.public.jbuilder.java.language
Article #700Re: Color to Hex string
From: Alan Shiers
Date: Wed, 01 Dec 2004 20:28
Date: Wed, 01 Dec 2004 20:28
32 lines
2308 bytes
2308 bytes
Thanks for explaining John. This method will do just fine for my purposes.
Alan
"John McGrath [TeamB]" <ng-b@JPMcGrath.net> wrote in message
news:xn0dqhv9r23j0pt008@newsgroups.borland.com...
> 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:
<41ae2a1f@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news3.google.com!news.glorb.com!transit.nntp.hccnet.nl!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!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> <xn0dqhv9r23j0pt008@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: "Alan Shiers" <ashiers@hfx.eastlink.ca> Newsgroups: borland.public.jbuilder.java.language References: <41acd295$1@newsgroups.borland.com> <xn0dqhf5t1hnd2f006@newsgroups.borland.com> <41adc82f$3@newsgroups.borland.com> <xn0dqhv9r23j0pt008@newsgroups.borland.com> Subject: Re: Color to Hex string Date: Wed, 1 Dec 2004 16:28:06 -0400 Lines: 34 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 NNTP-Posting-Host: 24.222.101.2 Message-ID: <41ae2a1f@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1101933087 24.222.101.2 (1 Dec 2004 12:31:27 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news3.google.com!news.glorb.com!transit.nntp.hccnet.nl!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail