<p>My Program overrides <code>public void paint(Graphics g, int x, int y);</code> in order to draw some stings using <code>g.drawString(someString, x+10, y+30);</code></p>

<p>Now someString can be quite long and thus, it may not fit on one line.<br></p>

<p>What is the best way to write the text on multiple line.<br> For instance, in a rectangle (x1, y1, x2, y2)?</p>

java.awt.font.TextLayout
might be helpful. Here's a snippet of their example code:
```
```
Graphics2D g = ...;
   Point2D loc = ...;
   Font font = Font.getFont("Helvetica-bold-italic");
   FontRenderContext frc = g.getFontRenderContext();
   TextLayout layout = new TextLayout("This is a string", font, frc);
   layout.draw(g, (float)loc.getX(), (float)loc.getY());

   Rectangle2D bounds = layout.getBounds();
   bounds.setRect(bounds.getX()+loc.getX(),
                  bounds.getY()+loc.getY(),
                  bounds.getWidth(),
                  bounds.getHeight());
   g.draw(bounds);
```
```
Otherwise you could always use a Swing text element to do the job for you, just pass in the Graphics you want it to paint into.