title: Using recursion in method paint() for fractal
body: <p>I'm learning recursion and I'm trying to make a fractal H-tree using java. I have my method called simple H which makes the H tree of order 1. The head of my method is this one:</p>
  
  <pre><code>public void simpleH(Graphics g, int x, int y, int size){
      g.drawLine(x, y, x, y+tamaño); //right
      g.drawLine(x, y+tamaño/2, x+tamaño, y+tamaño/2); //middle
      g.drawLine(x+tamaño,y,x+tamaño,y+tamaño); //left
  }
  </code></pre>
  
  <p>What I'm trying to do is using the paint() method to redraw the H tree using a recursive method but I'm stuck because I can't find the way to call my simpleH method to draw a H tree in order 2,3,4 depending on what the user inputs. AlSO, I'm struggling because I cant call the paint() method to draw the lines. Anyone can give me some hints? </p>
  
  <pre><code>public void paint(Graphics g,int n, int x, int y, int size){
      if(n==0){
          return;
      }
  int x1 = x-size/2;
      int y1=y;
      int x2=x+size/2;
      int y2=y;
      g.drawLine(x1, y1, x2, y2);
  
      //left line
      y1 = y-size/2;
      x2=x1;
      y2=y+size/2;
      g.drawLine(x1, y1, x2, y2);
  
      //left recursion
      paint(g,n-1,x1,y1,size/2);
      paint(g,n-1,x2,y2,size/2);
  
      //right line
      x1=x+size/2;
      x2=x;
      g.drawLine(x1, y1, x2, y2);
  
      //right recursion
      paint(g,n-1,x1,y1,size/2);
      paint(g,n-1,x2,y2,size/2);
  </code></pre>