The stringWidth Method
To determine the width of the string s in the current font: FontMetrics fm = g.getFontMetrics(); int stringWidth = fm.stringWidth( s );where g is a Graphics object
To determine the string height, simply add the ascent and descent of the current font