Here you can find the source of getRandomColor()
public static String getRandomColor()
//package com.java2s; // it under the terms of the GNU General Public License as published by import java.awt.Color; public class Main { public static String getRandomColor() { String col = Integer.toHexString(new Color( (int) (Math.random() * 0xffffff)).darker().getRGB()); while (col.length() < 6) { col = "0" + col; }// w w w . j av a 2 s . c om return col.substring(col.length() - 6); } }