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 ) ) );
精彩评论