Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Getting the hex colour code of a Jpanel background colour

807599Apr 16 2007 — edited Apr 16 2007
Hello,

I have been attempting to retreive the hex colour code of a jPanel's background colour, so far I have the code
Integer.toHexString(jPanelgetBackground().getRGB()));
However this is returning an 8 digit string (for example. if the jpanels background color is white, this will return ffffffff instead of a the six digit value ffffff that I want. If I try black 000000 my code returns ff000000.

I am trying to retreive the colour and then use it in a CSS file. However every time there is an extra ff added to the start of the string. Where am I going wrong?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 14 2007
Added on Apr 16 2007
2 comments
287 views