Here you can find the source of encode(Color color)
public static String encode(Color color)
//package com.java2s; import java.awt.Color; public class Main { public static String encode(int number) { if ((number < 0) || (number > 255)) throw new IllegalArgumentException("" + number); String hex = "0123456789ABCDEF"; char c1 = hex.charAt(number / 16); char c2 = hex.charAt(number % 16); return c1 + "" + c2; }//from w ww .j a v a2s. co m public static String encode(Color color) { return "#" + encode(color.getRed()) + encode(color.getGreen()) + encode(color.getBlue()); } }