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

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转为html里所用的颜色代码)