How to Change Font Size in drawString Java

zbz.lvlv picture zbz.lvlv · Aug 15, 2013 · Viewed 192.4k times · Source

How to make the font size bigger in g.drawString("Hello World",10,10); ?

Answer

John Snow picture John Snow · Aug 15, 2013
g.setFont(new Font("TimesRoman", Font.PLAIN, fontSize)); 

Where fontSize is a int. The API for drawString states that the x and y parameters are coordinates, and have nothing to do with the size of the text.