Here you can find the source of randomColor()
public static int randomColor()
//package com.java2s; //License from project: Open Source License import java.util.Random; public class Main { private static final Random RANDOM = new Random(); public static int randomColor() { return RANDOM.nextInt(256); }/* w w w . j a va2 s. c o m*/ public static int randomColor(int from, int to) { assertColor(from); assertColor(to); if (from > to) { throw new IllegalArgumentException("From can't be larger than to"); } if (from == to) { return from; } else { return RANDOM.nextInt(to - from + 1) + from; } } public static void assertColor(int color) { if (color < 0 || color > 255) { throw new IllegalArgumentException("Color outside of range 0 - 255"); } } }