Java tutorial
//package com.java2s; import java.awt.*; public class Main { /** * Get the string height in the context of Graphics. * * @param g * The <code>Graphics</code>. * @return The height <code>int</code>. */ public static int getStringHeight(final Graphics g) { final FontMetrics fontMetrics = g.getFontMetrics(); return fontMetrics.getMaxAscent() + fontMetrics.getMaxDescent(); } }