Reputation: 9800
Is there any way to use HTML hash color code for Font?
I mean #FFFFFF
to use it for
g2d.setColor(Color.white);
Upvotes: 2
Views: 12108
Reputation: 108957
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");
Upvotes: 10
Reputation: 12561
g2d.setColor( new Color( Integer.parseInt( "FFFFFF", 16 ) ) );
Upvotes: 4