@Override
    public void mouseDragged(MouseEvent event) {
      if (pos == -1)
        return;

      /*Point loc = getLocation();
      displacement =  event.getPoint();
      points[1].setRect(points[1].getX()-displacement.x,points[1].getY()-displacement.y,points[1].getWidth(),points[1].getHeight());*/
      
      
      /*if(pos==0){
        
        points[1].setRect(points[1].getX()-event.getPoint().x,points[1].getY()-event.getPoint().y,points[1].getWidth(),points[1].getHeight());
      }*/
      //else
      
      
      // for bottom right corner
      points[1].setRect(event.getPoint().x,event.getPoint().y,points[pos].getWidth(),points[pos].getHeight()); 
      System.out.println("dragged x y="+event.getPoint().x+" "+event.getPoint().y);
      
      repaint();
    }