title: Maze drawing using Java GUI - rectangles are printed one over the other
body: <p>Given the following code : </p>
  
  <pre><code>private void drawMaze(PaintEvent e)
  {
          Graph maze = new Graph();
          maze.generateMaze(25);
  
          int i = 0;
          int level = 25;
  
      e.gc.setAntialias(SWT.ON);
      e.gc.setBackground(new Color(e.display, 150, 150, 150));
      e.gc.setLineWidth(12);
  
      while (i &lt; level)
      {
          Connector connector = maze.getEdgeConnectorByIndex(i);
          if (connector instanceof Door)
              {
                 Room room1 = ((Door)connector).getFirstRoom();
                 Room room2 = ((Door)connector).getSecondRoom();
                 int x = room1.getXcoordinate()+10;
                 int y = room1.getYcoordinate()+10;
  
                 System.out.println(x);
                 System.out.println(y);
  
                 e.gc.fillRectangle(x,y,100,79);
                 e.gc.setBackground(e.display.getSystemColor(SWT.COLOR_BLUE));
                 e.gc.setForeground(e.display.getSystemColor(SWT.COLOR_GREEN));  
                 e.gc.drawLine(x,y, 280+100,20); 
  
              }
          i++;
      }
  
  }
  </code></pre>
  
  <p>class BasicShapes</p>
  
  <pre><code>public class BasicShapes {
  
  
  
      private Shell shell;
  
      public BasicShapes(Display display) {
  
          shell = new Shell(display);
  
          shell.addPaintListener(new ExmaplePaingListener());
  
          shell.setText("Basic shapes");
          shell.setSize(1000, 700);
          shell.setLocation(50, 50);
          shell.open();
  
          while (!shell.isDisposed()) {
              if (!display.readAndDispatch()) {
                  display.sleep();
              }
          }
      }
  
      private class ExmaplePaingListener implements PaintListener {
  
          public void paintControl(PaintEvent e) {
  
              // drawRectangles(e);
              drawMaze(e);
              e.gc.dispose();
          }
      }
  
  
  
  ...
  
  }
  </code></pre>
  
  <p>I need to draw maze , with separators as Door/Wall between each two cells.
  In the method drawMaze() , I first create a graph G=(V,E) with vertices &amp; edges (vertices=rooms , edges=Door/Wall) and then I want to use it . </p>
  
  <p>It the while loop , I run the loop by the number of edges , and each time I get
  the coordinates of two rooms (in the x,y plane) and I want to print the 1ST room , with the connector (wall/door) with the other room , but every time the first room is printed on the other (and for the rest of the edges also).</p>
  
  <p>How can I fix it ? </p>
  
  <p>Regards,Ron</p>