Here you can find the source of toHexColor(final Color color)
Parameter | Description |
---|---|
color | Color to get hexidecimal string from. |
public static String toHexColor(final Color color)
//package com.java2s; import java.awt.Color; public class Main { /**//from w w w .j a v a2 s.co m * Converts a given color to it's hexidecimal equivalent. * * @param color Color to get hexidecimal string from. * @return Hexidecimal string representing the given color, in the form "#abcdef". */ public static String toHexColor(final Color color) { return "#" + colorToHexCode(color); } /** * Gets the RGB hex color code of the passed color. * * @param color The color to get a hex code from. * @return A lower-cased string of the RGB hex code of color. */ public static String colorToHexCode(final Color color) { return String.format("%06x", color.getRGB() & 0xFFFFFF); } }