Here you can find the source of drawString(Graphics g, String text, int x, int y)
public static void drawString(Graphics g, String text, int x, int y)
//package com.java2s; //License from project: Open Source License import java.awt.Graphics; public class Main { public static void drawString(Graphics g, String text, int x, int y) { for (String line : text.split("\n")) g.drawString(line, x, y += g.getFontMetrics().getHeight()); }// w w w .ja v a2 s . c om }