Java examples for 2D Graphics:Color HEX
Return the given color to hex code.
//package com.java2s; import javafx.scene.paint.Color; public class Main { /**/*from w w w . ja v a 2 s . c o m*/ * Return the given color to hex code. * E.g. Color white is #FFFFFF. * * @param color * @return hex color String */ public static String getRGBCode(Color color) { return String.format("#%02X%02X%02X", (int) (color.getRed() * 255), (int) (color.getGreen() * 255), (int) (color.getBlue() * 255)); } }