Here you can find the source of toHexString(Color color)
public static String toHexString(Color color)
//package com.java2s; //License from project: Open Source License import java.awt.*; public class Main { public static String toHexString(Color color) { return String.format("#%06x", (color.getRGB() & 0x00ffffff)); }//from w w w.j ava 2s .co m }