Java String to convertStringToColor(String color)

Here you can find the source of convertStringToColor(String color)

Description

convert String To Color

License

Open Source License

Declaration

static Color convertStringToColor(String color) 

Method Source Code

//package com.java2s;

public class Main {
    static Color convertStringToColor(String color) {
        Color colorConverted = Color.black; //Default//
        if (color.equals("black")) {
            colorConverted = Color.black;
        }//from  w w w.  j ava 2s .c o m
        if (color.equals("red")) {
            colorConverted = Color.red;
        }
        if (color.equals("blue")) {
            colorConverted = Color.blue;
        }
        if (color.equals("green")) {
            colorConverted = Color.green;
        }
        if (color.equals("orange")) {
            colorConverted = Color.orange;
        }
        return colorConverted;
    }
}

Related

  1. convertStringArrayToString(String[] a_asStrings, String a_sDelim)
  2. convertStringArrayToString(String[] value, String separator)
  3. convertStringFormat(String property)
  4. convertStringsToTextSet(String[] values)
  5. convertStringToArray(String str)
  6. ConvertStringToEnumValue(String enumAsString, Class type)
  7. convertStringToFloat(String str)
  8. convertStringToId(String s)
  9. convertStringToIntDef(String string, int defaultValue)