Java tutorial
//package com.java2s; import java.awt.Color; public class Main { /** * Parse string value as Color. Return default value if source * string is null. * @param value String * @param defValue int - color value in RGB * @return Color */ public static Color getAsColor(String value, int defValue) { Color result = new Color(defValue); if (value != null) { try { result = new Color(Integer.parseInt(value, 16)); } catch (NumberFormatException ex) { } } return result; } /** * Parse string value as Color. Return default value if source * string is null. * @param value String * @param defValue Color * @return Color */ public static Color getAsColor(String value, Color defValue) { Color result = defValue; if (value != null) { try { result = new Color(Integer.parseInt(value, 16)); } catch (NumberFormatException ex) { } } return result; } }