您的位置:首页 > Web前端 > HTML

把一个Color转为html里所用的颜色代码

2016-04-09 01:13 309 查看
public String getColorCode(Color color) {
String string;
return "#" + ((string = Integer.toHexString(color.getRed())).length() == 2 ? string : ("0" + string))
+ ((string = Integer.toHexString(color.getGreen())).length() == 2 ? string : ("0" + string))
+ ((string = Integer.toHexString(color.getBlue())).length() == 2 ? string : ("0" + string));
}

可能以后用得上。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Color