Here you can find the source of decodeColor(String color, Color defaultColor)
public static Color decodeColor(String color, Color defaultColor)
//package com.java2s; //License from project: Open Source License import java.awt.Color; import java.util.Hashtable; public class Main { public static Hashtable HTMLColors; public static Color decodeColor(String color, Color defaultColor) { String colorVal = ""; if (color.length() > 0) { colorVal = color.trim();// w w w .j a v a2 s. c om if (colorVal.startsWith("#")) colorVal = colorVal.substring(1); try { colorVal = new Integer(Integer.parseInt(colorVal, 16)).toString(); return Color.decode(colorVal.toLowerCase()); } catch (Exception ex) { ex.printStackTrace(); } } else return defaultColor; return getColorForName(color, defaultColor); } public static Color decodeColor(String color) { return decodeColor(color, Color.white); } public static Color getColorForName(String name, Color defaultColor) { if (HTMLColors.contains(name.toLowerCase())) return (Color) HTMLColors.get(name.toLowerCase()); return defaultColor; } }