首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

怎么用十六进制的数生成颜色对象

2012-02-04 
如何用十六进制的数生成颜色对象如题,例如用 #FFFFFF生成一个 Color 对象[解决办法]public Color getColor

如何用十六进制的数生成颜色对象
如题,例如用 #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;
}

热点排行