• Advertisement
Sign in to follow this  

[java] Outline text

This topic is 4548 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How would I go about outlining text in my game? I've tried
g.setColor(Color.Black);
g.drawString("test", x - 1, y + 1);
g.drawString("test", x - 1, y - 1);
g.drawString("test", x + 1, y + 1);
g.drawString("test", x + 1, y - 1);

g.setColor(Color.yellow);
g.drawString("test", x, y);

but it doesn't seem to result in a perfect outline. Any help?

Share this post


Link to post
Share on other sites
Advertisement
Dont use that API for drawing at all, it's deprecated (effectively if not officially).

You want Java2D, part of the standard libraries, look for the Grapihcs2D class - theres full docs on the sun java tutorials in the standard place - and all the classes that come from Shape.

All the Shape classes can be "filled" or "drawn", and you have fine control over the thickness of outline etc. IIRC there's text-drawing capabilities wihtin that too (look at the Stroke and Paint classes)

Share this post


Link to post
Share on other sites
...just my two cents: if you're using a very thin font (what i supose. I bet you're using the default one.) you should simply draw the background string in the 9 directions insteand of 4! :P

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement