开发者

Using HTML Color code in JAVA Font color

Is there any way to use HTML开发者_如何学Go hash color code for Font?

I mean #FFFFFF to use it for

g2d.setColor(Color.white);


you can try

int intValue = Integer.parseInt( "FFFFFF",16);
Color aColor = new Color( intValue );

EDIT:

To get color by name, you could use reflection,

Color aColor   = (Color) Color.class.getField("white").get(null);

EDIT 2:

from @eee

Color aColor = Color.decode("#FFFFFF");

or

Color aColor = Color.decode("0xFFFFFF");


g2d.setColor( new Color( Integer.parseInt( "FFFFFF", 16 ) ) );
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜