Java Color from String StringToColor(String name)

Here you can find the source of StringToColor(String name)

Description

String To Color

License

Open Source License

Declaration

public static Color StringToColor(String name) 

Method Source Code


//package com.java2s;
import java.awt.Color;

import java.util.Hashtable;

public class Main {
    static private Hashtable<String, Color> reverseColorsHashtable = null;

    public static Color StringToColor(String name) {
        Color new_color = null;
        try {/*from   w w  w  .  java  2  s  .c  o m*/
            if (null != reverseColorsHashtable) {
                new_color = reverseColorsHashtable.get(name);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            if (null == new_color) {
                new_color = Color.getColor(name);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return new_color;
    }
}

Related

  1. stringToColor(final String value)
  2. stringToColor(String color)
  3. stringToColor(String color)
  4. stringToColor(String colorName)
  5. stringToColor(String colorString)
  6. stringToColor(String s)
  7. stringToColor(String s)
  8. stringToColor(String s)
  9. stringToColor(String s, boolean nullIfInvalid)