Here you can find the source of drawMultiLineText(String text, Graphics G, int x, int y)
public static void drawMultiLineText(String text, Graphics G, int x, int y)
//package com.java2s; //License from project: Apache License import java.awt.*; import java.util.*; public class Main { public static void drawMultiLineText(String text, Graphics G, int x, int y) { FontMetrics metrics = G.getFontMetrics(); StringTokenizer str = new StringTokenizer(text, "\n\r"); int height = y; while (str.hasMoreTokens()) { String token = str.nextToken(); G.drawString(token, x, height + metrics.getAscent()); height += (metrics.getAscent() + metrics.getLeading()); }//from w w w.j a v a2s .c om } }