日期:2014-05-20  浏览次数:20709 次

如何用十六进制的数生成颜色对象
如题,例如用 #FFFFFF 生成一个 Color 对象

------解决方案--------------------
public Color getColor(String col){
if(col.length()==7){
return new Color(Integer.parseInt(col.substring(1,3),16),Integer.parseInt(col.substring(3,5),16),Integer.parseInt(col.substring(5,7),16));
}
return null;
}