Java Color from String stringToColor(String s, boolean nullIfInvalid)

Here you can find the source of stringToColor(String s, boolean nullIfInvalid)

Description

string To Color

License

Open Source License

Declaration

public static Color stringToColor(String s, boolean nullIfInvalid) 

Method Source Code


//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;
        }
    }
}

Related

  1. stringToColor(String colorString)
  2. StringToColor(String name)
  3. stringToColor(String s)
  4. stringToColor(String s)
  5. stringToColor(String s)
  6. stringToColorNoDefault(String string)
  7. webColorCodeToJava(String value)