Java tutorial
//package com.java2s; import java.awt.Color; public class Main { /** * Returns a random color. */ public static Color getRandColor() { return new Color((int) (Math.random() * 255), (int) (Math.random() * 255), (int) (Math.random() * 255)); } public static Color getRandColor(int threashold) { if (threashold < 0 || threashold > 255) throw new IllegalArgumentException("Threashold is not between 0 and 255"); int secondOperand = 255 - threashold; return new Color((int) (Math.random() * secondOperand) + threashold, (int) (Math.random() * secondOperand) + threashold, (int) (Math.random() * secondOperand) + threashold); } }