Java Color Create generateRGBRandomColor()

Here you can find the source of generateRGBRandomColor()

Description

Generate random RGB color.

License

Apache License

Declaration

public static Color generateRGBRandomColor() 

Method Source Code


//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);
    }
}

Related

  1. generateGreyColor(double value, double minValue, double maxValue)
  2. generateHexolor(Color color)
  3. generateNColors(int numColors)
  4. generateNextValidColor()
  5. generatePallete(final int colours)
  6. generateTexturePaint(String text, Font font, Color textColor, Color bgColor, int width, int height)
  7. generateVisuallyDistinctColors(int ncolors, float minComponent, float maxComponent)
  8. toColor(byte red, byte green, byte blue)
  9. toColor(byte[] bytes)