Java examples for 2D Graphics:Color RGB
Get hex from RGB
//package com.java2s; public class Main { public static void main(String[] argv) throws Exception { int red = 2; int green = 2; int blue = 2; System.out.println(getColorHex(red, green, blue)); }/*from ww w . j a va 2 s .c om*/ /**Get hex from RGB*/ public static int getColorHex(int red, int green, int blue) { return ((red & 0x0FF) << 16) | ((green & 0x0FF) << 8) | (blue & 0x0FF); } }