I've got to write this java applet, and I was wondering if anyone knows how to find the number of pixels long a string is. I'm guess it varies based on your resolution, but I don't know if there is anyway of overcoming it. If there isn't, I'd be happy if I could get it to work on 800x600.

Its a pretty simple program (writing underlined text inside an oval that is transcribed in a rectangle). To underline the string, our professor wants us to use drawLine from java.awt.Graphics. Since it determines the starting and ending points in terms of pixels, I need to know how many pixels long the string is.