Here you can find the source of getRandomColor()
public static String getRandomColor()
//package com.java2s; //License from project: LGPL import java.util.Random; public class Main { public static String getRandomColor() { Random ra = new Random(); int r, g, b; r = ra.nextInt(255);/*from w ww . java 2s . c om*/ g = ra.nextInt(255); b = ra.nextInt(255); String hex = String.format("#%02x%02x%02x", r, g, b); return hex; } }