Here you can find the source of randomColor()
public static java.awt.Color randomColor()
//package com.java2s; //License from project: Open Source License import java.util.concurrent.ThreadLocalRandom; public class Main { /**// w ww.ja v a 2 s. c om * Generates and returns a random RGB {@code Color}. * * @return A random {@code Color}. */ public static java.awt.Color randomColor() { return new java.awt.Color(randomInteger(0, 255), randomInteger(0, 255), randomInteger(0, 255)); } /** * Generates and returns a pseudorandom integer value between {@code min} * and {@code max} (inclusive). * * @param min The minimum range value, inclusive. * @param max The maximum range value, inclusive. * @return A pseudorandom integer value between {@code min} and {@code max} * arguments(inclusive). */ public static int randomInteger(int min, int max) { return ThreadLocalRandom.current().nextInt(min, max + 1); } }