Here you can find the source of encodeColor(Color color)
Parameter | Description |
---|---|
color | Color to encode |
public static String encodeColor(Color color)
//package com.java2s; //License from project: Open Source License import java.awt.Color; public class Main { /**//from w w w. j a v a 2s . co m * Converts a Color to a hex color string. For example Color.GREEN will return "#00FF00". * @see java.awt.Color#decode(String) which does the opposite * @param color Color to encode * @return A hex Color string in the format #rrggbb. */ public static String encodeColor(Color color) { if (color == null) { //If no color, then return a middle-of-the-road gray. return "#808080"; } return "#" + String.format("%06x", color.getRGB() & 0xffffff); } }