question: static final Color hexToColor ( String value ) { String digits ; int n = value . length ( ) ; if ( value . startsWith ( "#" ) ) { digits = value . substring ( 1 , Math . min ( value . length ( ) , 7 ) ) ; } else { digits = value ; } String hstr = "0x" + digits ; Color c ; try { c = Color . decode ( hstr ) ; } catch ( NumberFormatException nfe ) { c = null ; } return c ; }
target:  Convert a "#FFFFFF" hex string to a Color. If the color specification is bad, an attempt will be made to fix it up.