Here you can find the source of string2color(String str)
Parameter | Description |
---|---|
str | java.lang.String |
public static java.awt.Color string2color(String str)
//package com.java2s; import java.awt.Color; public class Main { /**//from w w w . jav a 2s . co m * Insert the method's description here. * Creation date: (23.4.2001 18:52:04) * @return java.awt.Color * @param str java.lang.String */ public static java.awt.Color string2color(String str) { int rgb = Integer.parseInt(str); // !!! add more or use flyweight switch (rgb) { case 0x000000: return Color.black; case 0x0000ff: return Color.blue; case 0x00ff00: return Color.green; case 0xff0000: return Color.red; case 0xffffff: return Color.white; default: return new Color(rgb); } } }