if (oldwidth != 0 && oldheight != 0 && parent != null)
boolean shouldRepaintParent = false; boolean shouldRepaintSelf = false;  if (parent != null) { Rectangle parentBounds = parent.getBounds(); Rectangle oldBounds = new Rectangle(parent.getX() + oldx, parent.getY() + oldy, oldwidth, oldheight); Rectangle newBounds = new Rectangle(parent.getX() + x, parent.getY() + y, width, height); shouldRepaintParent = parentBounds.intersects(oldBounds); shouldRepaintSelf = parentBounds.intersects(newBounds); }  if (shouldRepaintParent)
  public void reshape(int x, int y, int width, int height)  {    int oldx = this.x;    int oldy = this.y;    int oldwidth = this.width;    int oldheight = this.height;    if (this.x == x && this.y == y        && this.width == width && this.height == height)      return;    invalidate ();    this.x = x;    this.y = y;    this.width = width;    this.height = height;    if (peer != null)      peer.setBounds (x, y, width, height);    // Erase old bounds and repaint new bounds for lightweights.    if (isLightweight())      {        if (oldwidth != 0 && oldheight != 0 && parent != null)          parent.repaint(oldx, oldy, oldwidth, oldheight);        if (width != 0 && height != 0)          repaint();      }    if (oldx != x || oldy != y)      {        ComponentEvent ce = new ComponentEvent(this,                                               ComponentEvent.COMPONENT_MOVED);        getToolkit().getSystemEventQueue().postEvent(ce);      }    if (oldwidth != width || oldheight != height)      {        ComponentEvent ce = new ComponentEvent(this,                                               ComponentEvent.COMPONENT_RESIZED);        getToolkit().getSystemEventQueue().postEvent(ce);      }	}