title: Draw Random thickness lines
body: <p>I'm trying to use <code>setStroke</code> and <code>BasicStroke</code> to draw random thickness lines.</p>
  
  <p>here is the painting code</p>
  
  <pre><code> public void paintComponent(Graphics g1) {
          Random rand = new Random();
          Graphics g2 = (Graphics2D) g1;
  
          //set background color
          g2.setColor(Color.white);
          g2.fillRect(0, 0, getWidth(), getHeight());
          Dimension d = getPreferredSize();
  
          //set  line's color
  
          float r = rand.nextFloat();
          float g = rand.nextFloat();
          float b = rand.nextFloat();
  
          Color randomColor = new Color(r,g,b);
  
          g2.setColor(randomColor);
  
          //set line's stroke
  
          float width = rand.nextFloat();
  
          BasicStroke randomStroke = new BasicStroke(width);
  
  
          ((Graphics2D) g2).setStroke(randomStroke);
  
  
          for (Line2D.Double line : lines) {
              g2.drawLine(
                  (int)line.getX1(),
                  (int)line.getY1(),
                  (int)line.getX2(),
                  (int)line.getY2()
                  );
          }
      }
  </code></pre>
  
  <p>when I set the width of stroke to a certain number, it can draw correctly. I looked up the <code>BasicStroke</code> class, it have the following parameters: </p>
  
  <pre><code>  float width;
    int join;
    int cap;
    float miterlimit;
    float[] dash;
    float dash_phase;
  </code></pre>
  
  <p>Besides width, I'm not sure what are the others function. 
  How can I use the <code>BasicStroke</code> to generate random thickness lines?</p>