Getting the hex colour code of a Jpanel background colour

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?

[594 byte] By [kingcrimsonatora] at [2007-11-27 1:12:23]
# 1
Integer.toHexString(jPanel.getBackground().getRGB() & 0xffffff);Message was edited by: sabre150
sabre150a at 2007-7-11 23:47:43 > top of Java-index,Java Essentials,New To Java...
# 2
Much appreciated Sabre!
kingcrimsonatora at 2007-7-11 23:47:43 > top of Java-index,Java Essentials,New To Java...