Rectangle2D.intersect(rect, new Rectangle(0, 0, getWidth(), getHeight()), rect);
rect = SwingUtilities.computeIntersection(0, 0, getWidth(), getHeight(), rect);
  public void computeVisibleRect(Rectangle rect)  {    Component c = getParent();    if (c != null && c instanceof JComponent)      {        ((JComponent) c).computeVisibleRect(rect);        rect.translate(-getX(), -getY());        Rectangle2D.intersect(rect,                              new Rectangle(0, 0, getWidth(), getHeight()),                              rect);      }    else      rect.setRect(0, 0, getWidth(), getHeight());  }