import java.awt.Color;
import java.util.Random;
public class RandomColorGenerator {
public static Color generateRandomColor() {
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);
import java.awt.Color;
import java.util.Random;
public class RandomColorGenerator {
public static Color generateRandomColor() {
Random random = new Random();
int red = random.nextInt(101); // 生成0到100之间的随机数
int green = random.nextInt(256);
int blue = random.nextInt(256);
return new Color(red, green, blue);
import java.awt.Color;
import java.util.Random;
public class RandomColorGenerator {
public static Color generateRandomColor() {
Random random = new Random();
int red = random.nextInt(256);
int green = random.nextInt(256);
int blue = random.nextInt(256);
Color color = new Color(red, green, blue);
float brightness = color.getBrightness();
if (brightness < 0.5) {
// 生成的颜色为暗色
// 在这里进行相应的处理
} else {
// 生成的颜色为亮色
// 在这里进行相应的处理
return color;