Here you can find the source of getTextHeight(String text, Graphics g, String newLineSplit)
public static int getTextHeight(String text, Graphics g, String newLineSplit)
//package com.java2s; //License from project: Open Source License import java.awt.Graphics; public class Main { public static int getTextHeight(String text, Graphics g, String newLineSplit) { return g.getFontMetrics().getHeight() * text.split(newLineSplit).length; }/*from ww w. j a va 2 s .c o m*/ }