import java.awt.Color;
import java.util.Random;
public class RandomColorGenerator {
public static void main(String[] args) {
Random random = new Random();
int red = random.nextInt(256);
int green = random.nextInt(256);
int blue = random.nextInt(256);
Color randomColor = new Color(red, green, blue);
String colorCode = "#" + Integer.toHexString(randomColor.getRGB()).substring(2).toUpperCase();
System.out.println("随机颜色代码: " + colorCode);
import java.awt.Color;
import java.util.Random;
public class RandomBrightColorGenerator {
public static void main(String[] args) {
Random random = new Random();
int red = random.nextInt(256);
int green = random.nextInt(256);
int blue = random.nextInt(256);
Color randomColor = new Color(red, green, blue);
// 增加亮度
Color brighterColor = randomColor.brighter();
System.out.println("增加亮度的颜色代码: #" + Integer.toHexString(brighterColor.getRGB()).substring(2).toUpperCase());
// 减少亮度
Color darkerColor = randomColor.darker();
System.out.println("减少亮度的颜色代码: #" + Integer.toHexString(darkerColor.getRGB()).substring(2).toUpperCase());