Example usage for java.util Random Random

List of usage examples for java.util Random Random

Introduction

In this page you can find the example usage for java.util Random Random.

Prototype

public Random() 

Source Link

Document

Creates a new random number generator.

Usage

From source file:Main.java

public static int getRandomColor() {
    Random rndcolor = new Random();
    int color = Color.argb(255, rndcolor.nextInt(256), rndcolor.nextInt(256), rndcolor.nextInt(256));
    return color;
}

From source file:Main.java

public static String getRandomColor() {
    Random rand = new Random();
    Integer randomColor = Color.rgb(rand.nextInt(), rand.nextInt(), rand.nextInt());
    return randomColor.toString();
}

From source file:Main.java

public static int randomColor() {
    Random random = new Random();
    int red = random.nextInt(150) + 50;
    int green = random.nextInt(150) + 50;
    int blue = random.nextInt(150) + 50;
    return Color.rgb(red, green, blue);
}

From source file:Main.java

public static int randomIndex(Collection<?> collection) {
    return new Random().nextInt(collection.size());
}

From source file:Main.java

public static int generateColor() {
    Random random = new Random();

    final float hue = random.nextInt(360);
    final float saturation = (random.nextInt(7000) + 2000) / 10000f;
    final float luminance = 0.3f;
    float[] hsv = { hue, saturation, luminance };
    return Color.HSVToColor(hsv);
}

From source file:Main.java

public static int randomColor() {
    Random random = new Random();
    int red = random.nextInt(150) + 50;//50-199
    int green = random.nextInt(150) + 50;//50-199
    int blue = random.nextInt(150) + 50;//50-199
    return Color.rgb(red, green, blue);
}

From source file:Main.java

public static String getRandomRGB() {
    String r, g, b;/*from ww  w . j av  a  2s  .co m*/
    Random random = new Random();
    r = Integer.toHexString(random.nextInt(256)).toUpperCase();
    g = Integer.toHexString(random.nextInt(256)).toUpperCase();
    b = Integer.toHexString(random.nextInt(256)).toUpperCase();
    r = r.length() == 1 ? "0" + r : r;
    g = g.length() == 1 ? "0" + g : g;
    b = b.length() == 1 ? "0" + b : b;
    return "#" + (r + g + b);
}

From source file:Main.java

public static String getSixRandom() {
    String str = "";
    Random random = new Random();
    for (int i = 0; i < 6; i++) {
        int itmp = random.nextInt(26) + 65;
        char ctmp = (char) itmp;
        str += ctmp;/*from   w w  w . ja v  a2s .c o  m*/
    }
    return str;
}

From source file:Main.java

public static int getRandomInt(int sek, int min, int max) {

    Random random = new Random();

    int temp = 0;

    do {/*from ww w. ja va 2  s . c  om*/
        temp = random.nextInt(sek);
    } while (temp < min || temp > max);

    return temp;
}

From source file:Main.java

public static int getRandomColor() {

    Random random = new Random();

    int red = random.nextInt(200) + 30;
    int gre = random.nextInt(200) + 30;
    int blu = random.nextInt(200) + 30;

    return Color.rgb(red, gre, blu);
}