import java.awt.*;
import javax.swing.*;

public class String01 extends JFrame {

  public String01() {
    setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
    setTitle("1. Beispiel mit drawString");
    this.getContentPane().add( new CCanvas(), BorderLayout.CENTER );
  }


    public static void main(String args[]) {
      String01 f = new String01();
      f.setSize(500,200);
      f.setVisible(true);
    }


}

class CCanvas extends Canvas {

  Font myFont=new Font("Arial", Font.ITALIC | Font.PLAIN, 36);

  public void paint (Graphics g)
  {
    int x = 80;
    Rectangle r = new Rectangle();
    g.getClipBounds(r);

   g.setFont(myFont);

  String s1="Hier ein String in java";

   g.drawString(s1, 30, 50);
   FontMetrics fontMetrics = g.getFontMetrics(myFont);
   int rowHeight = fontMetrics.getHeight();  // Konstant

    System.out.println("rowHeight: "+rowHeight);
   int row=rowHeight;
   for (int i=0; i<4; i++) {
      g.drawString("ohne Aliasing:"+i, 30, 50+row);
      row+=rowHeight;
   }
  }

}


