Here you can find the source of encodeColorForCss(Color color)
public static String encodeColorForCss(Color color)
//package com.java2s; //License from project: Open Source License import java.awt.Color; public class Main { public static String encodeColorForCss(Color color) { if (null == color) { return "#000000"; }/*from www . j a va 2 s.co m*/ return String.format("#%02x%02x%02x", color.getRed(), color.getGreen(), color.getBlue()).toUpperCase(); } }