Here you can find the source of toColor(String background)
Parameter | Description |
---|---|
background | A string representing the color. It will be given to Color#decode(String) . |
Parameter | Description |
---|---|
NumberFormatException | if the specified string cannot be interpretedas a decimal, octal, or hexidecimal integer. |
public static Color toColor(String background) throws NumberFormatException
//package com.java2s; /*//from w w w. ja va2 s .com * Geotoolkit - An Open Source Java GIS Toolkit * http://www.geotoolkit.org * * (C) 2008 - 2010, Geomatys * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ import java.awt.Color; public class Main { /** * Get the {@link Color} object matching with the given string. * * @param background A string representing the color. It will be given to * {@link Color#decode(String)}. * @return The color object, or {@code null} if the given string is {@code null}. * @throws NumberFormatException if the specified string cannot be interpreted * as a decimal, octal, or hexidecimal integer. */ public static Color toColor(String background) throws NumberFormatException { Color color = null; if (background != null) { background = background.trim(); color = Color.decode(background); } return color; } }