reesjones reesjones - 1 year ago 73
Java Question

How do I make drawString() text bold?

I have a

method in my
method. Is there a way to make the text drawn by the
bold? Also, is there a way to make the text bigger? I would like to avoid using
s, unless it is absolutely necessary.

Answer Source

According to documentation of drawString:

Draws the text given by the specified string, using this graphics context's current font and color. The baseline of the leftmost character is at position (x, y) in this graphics context's coordinate system

Indeed, Graphics class has the setFont(Font font) method available:

g.setFont(new Font("default", Font.BOLD, 16));