Java Example Program / Sample Source Code
import java.awt.Color;
import java.lang.reflect.Field;
public class PredefinedColors {
public static void main(String[] args) {
try {
// Find the field and value of colorName
// black, blue, cyan, darkGray, gray, green, lightGray, magenta, orange, pink, red, white, yellow
// You will get the values corresponding to the color
Field field = Class.forName("java.awt.Color").getField("gray");
System.out.println((Color) field.get(null));
} catch (Exception e) {
e.printStackTrace();
}
}
} |
|
|