A good answer might be:

gr.drawString("Loveliest of trees, the cherry now", 25, 30);
gr.drawString("Is hung with bloom along the bough", 25, 50 );

You want to start the second line at the same distance from the left edge as the first line, 25. If characters are 10 pixels high, you need to increase y from 30 to something greater than 40 (since there should be some space between lines.)

Slightly New Example

Say that an applet has a width of 300 pixels and a height of 150 pixels. You wish to write the word "Hello" roughly in the center of this area. Here is a partly completed applet that does that:

import java.applet.Applet;
import java.awt.*;

public class AnotherHello ___________________
  public void paint ( Graphics gr )
    setBackground( Color.lightGray );
    gr.drawString(____________, ____________, __________);

Say also that you know that the String "Hello" is 40 pixels wide.


Fill in the blanks.