Here you can find the source of toHex(Color color)
Parameter | Description |
---|---|
color | the color |
public static final String toHex(Color color)
//package com.java2s; import java.awt.Color; public class Main { /**//ww w . j av a 2 s . co m * Returns a hex string for the given color in RGB format. * <p> * Transparency is ignored. * @param color the color * @return String */ public static final String toHex(Color color) { int r = color.getRed(); int g = color.getGreen(); int b = color.getBlue(); return String.format("%02x", r) + String.format("%02x", g) + String.format("%02x", b); } }