public void addNotify() {
    // Record the size of the window prior to calling parents addNotify.
    Dimension d = getSize();

    super.addNotify();

    if (fComponentsAdjusted) return;

    // Adjust components according to the insets
    setSize(
        getInsets().left + getInsets().right + d.width,
        getInsets().top + getInsets().bottom + d.height);
    Component components[] = getComponents();
    for (int i = 0; i < components.length; i++) {
      Point p = components[i].getLocation();
      p.translate(getInsets().left, getInsets().top);
      components[i].setLocation(p);
    }
    fComponentsAdjusted = true;
  }