get Hex For Color - Java 2D Graphics

Java examples for 2D Graphics:Color HEX

Description

get Hex For Color

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        int c = 2;
        System.out.println(getHexForColor(c));
    }//w  w w .j ava  2 s.com

    public static String getHexForColor(int c) {
        return "#"
                + Integer.toHexString((c & 0xffffff) | 0x1000000)
                        .substring(1);
    }
}

Related Tutorials