ah ok thats the way you mean it, but where do you get the exact image height? to get the image as height as your text you need to know the text height ;)
The GreenfootImage methods 'getWidth' and 'getHeight' return the dimensions of the image. The GreenfootImage constructor that is being used creates an image having the line height created using the fontsize given in the current font. Using the GreenfootImage method 'getHeight' of the image returns in pixels an equivalent value of what 'fm.getHeight' should return in points (a point is 1/72 of an inch and the conversion to pixels in dependent on your hardware; so using points would display different on different machines).
where do you get the exact image height? to get the image as height as your text you need to know the text height ;)
FontMetrics getHeight() method returns the standard height of a line of text. You can subtract the leading (getLeading()) from this if you are only displaying a single line.
If you want to be absolutely sure that all of the text is visible, you could use getMaxAscent() + getMaxDescent() instead of getHeight().