There are some fancy, dirty tricks with the reflection API, but the simplest solution would be a line map for the values:
Map<String, Color> colorMap = new HashMap<String, Color>(); colorMap.put("Color.RED", Color.RED);
and then when you need color:
String myColor = "Color.RED"; graphics.setColor(colorMap.get(myColor));
source share