get Random Color - Java 2D Graphics

Java examples for 2D Graphics:Image Captcha

Description

get Random Color

Demo Code


//package com.java2s;
import java.util.Random;

import java.awt.Color;

public class Main {
    public static void main(String[] argv) throws Exception {
        System.out.println(getRandomColor());
    }//  w w w . java  2  s  .c o m

    private static Color getRandomColor() {
        Random r = new Random();
        Color c = new Color(r.nextInt(255), r.nextInt(255), r.nextInt(255));
        return c;
    }
}

Related Tutorials