Here you can find the source of generateRGBRandomColor()
public static Color generateRGBRandomColor()
//package com.java2s; /*/* w ww . j a v a2 s .c om*/ ************************************************************************************ * Copyright (C) 2001-2011 encuestame: system online surveys Copyright (C) 2011 * encuestame Development Team. * Licensed under the Apache Software License version 2.0 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software distributed * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR * CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. ************************************************************************************ */ import java.awt.Color; import java.util.Random; public class Main { /** * Generate random RGB color. * @return */ public static Color generateRGBRandomColor() { Random random = new Random(); int red = random.nextInt(256); int green = random.nextInt(256); int blue = random.nextInt(256); return new Color(red, green, blue); } }