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

public class Line07 extends JFrame {

  public Line07(String caption) {
    setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
    setTitle(caption);
    this.getContentPane().add( new CCanvas(), BorderLayout.CENTER );
  }


    public static void main(String args[]) {
      Line07 f = new Line07("7. Linie, Grafik2D");
      f.setSize(300,300);
      f.setVisible(true);
    }


}

class CCanvas extends Canvas {

  public void paint (Graphics g)
  {
    int x = 80;
    Rectangle r = new Rectangle();
    g.getClipBounds(r);
    System.out.println("in paint");

    Graphics2D g2 = (Graphics2D) g;
    float [] dashs = {80.0f, 5.0f, 20f, 2f};  // Länge Strich , Pause
    // BasicStroke(float width, int cap, int join, float miterlimit,
    //             float[] dash, float dash_phase)
    //  1.0f = miterlimit
    g2.setStroke( new BasicStroke(6.0f,  BasicStroke.CAP_BUTT,
          BasicStroke.JOIN_MITER, 1.0f, dashs, 0.0f ) );
  
    for (int i=10; i< r.getWidth()-10; i++) {
      x = (int) (6.0*Math.random());
      if (x==2)
      g.drawLine(i,20,i,(int)
          r.getHeight()-10 );
      //x += 1+ 3*Math.random();
    }
  }

}


