Java examples for 2D Graphics:Color String
encode Color to String
//package com.java2s; import java.awt.Color; public class Main { public static String encode(Color c) { return "#" + hex(c.getAlpha(), 2) + hex(c.getRed(), 2) + hex(c.getGreen(), 2) + hex(c.getBlue(), 2); }// w ww . j ava 2 s . c o m public static String hex(int i, int places) { String s = Integer.toHexString(i); while (s.length() < places) s = "0" + s; return s; } }