Here you can find the source of randomColor()
public static Color randomColor()
//package com.java2s; //License from project: LGPL import java.awt.*; import java.util.*; public class Main { static Random r = new Random(); public static Color randomColor() { return new Color(r.nextInt(255), r.nextInt(255), r.nextInt(255)); }/* www.ja va 2 s .co m*/ public static Color randomColor(int alpha) { return new Color(r.nextInt(255), r.nextInt(255), r.nextInt(255), alpha); } }