@Override
  public void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D) g;

    g2.setColor(Color.red);
    for (int i = 0; i < points.length; i++) {
      g2.fill(points[i]);
    }
    
    topLeftX = (int) points[0].getCenterX();
    topLeftY = (int) points[0].getCenterY();
    bottomRightX = (int) Math.abs(points[1].getCenterX()- points[0].getCenterX());
    bottomRightY = (int) Math.abs(points[1].getCenterY()- points[0].getCenterY());
    //s.setRect(topLeftX, topLeftY, bottomRightX, bottomRightY);
    Point loc = getLocation();
    System.out.println(loc.x+" "+loc.y);
    
    
    /*setLocation((int)loc.x+displacement.x,(int)loc.y+displacement.y);
    setSize(bottomRightX+10,bottomRightY+10);
    s.setRect(points[0].getCenterX(),points[0].getCenterY(),bottomRightX,bottomRightY); */
    
    // for bottom right corner
    setSize(bottomRightX+10,bottomRightY+10);
    s.setRect(points[0].getCenterX(),points[0].getCenterY(),bottomRightX,bottomRightY); 

    g2.draw(s);
  }