Java examples for 2D Graphics:Color String
returns a hexadecimal string representation of the color - eg "AABBCC" or "DDAABBCC" The DD in this case gives the opacity value
/** Copyright by Barry G. Becker, 2000-2011. Licensed under MIT License: http://www.opensource.org/licenses/MIT */ //package com.java2s; import java.awt.*; public class Main { /**//w w w . j av a 2 s. c om * returns a hexadecimal string representation of the color - eg "AABBCC" or "DDAABBCC" * The DD in this case gives the opacity value * @return html color */ public static String getHTMLColorFromColor(Color color) { int intval = color.getRGB(); intval -= 0xFF000000; //System.out.println("NodePres getString from PathColor = "+Integer.toHexString(intval).toUpperCase()); return '#' + Integer.toHexString(intval).toUpperCase(); } }