get Background Color Random - Java 2D Graphics

Java examples for 2D Graphics:Color

Description

get Background Color Random

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        System.out.println(getBgColorRandom());
    }//from  w w w .ja v a 2  s  .  co  m

    private static String[] COLORS = new String[] { "f44336", // RED
            "e91e63", // PINK
            "9c27b0", // PURPLE
            "673ab7", // DEEP PURPLE
            "3f51b5", // INDIGO
            "2196f3", // BLUE
            "03a9f4", // LIGHT BLUE
            "00bcd4", // CYAN
            "009688", // TEAL
            "4caf50", // GREEN
            "8bc34a", // LIGHT GREEN
            "cddc39", // LIME
            "ffeb3b", // YELLOW
            "ffc107", // AMBER
            "ff9800", // ORANGE
            "ff5722", // DEEP ORANGE
            "795548", // BROWN
            "9e9e9e", // GREY
            "607d8b", // BLUE GREY
    };

    public static String getBgColorRandom() {
        int index = (int) (Math.random() * COLORS.length);
        return COLORS[index];
    }
}

Related Tutorials