Here you can find the source of stringToColor(String s, boolean nullIfInvalid)
public static Color stringToColor(String s, boolean nullIfInvalid)
//package com.java2s; //License from project: Open Source License import java.awt.Color; public class Main { public static Color stringToColor(String s, boolean nullIfInvalid) { try {//from w w w . jav a 2 s .c om return new Color(Integer.parseInt(s, 16)); } catch (Exception e) { return nullIfInvalid ? null : Color.WHITE; } } }