@Override
    public void addNotify() {
        // Record the size of the window prior to calling parents addNotify.
        Dimension dimension = getSize();
        super.addNotify();
        if (componentsAdjusted) {
            return;
        }
        // Adjust components according to the insets
        setSize(getInsets().left + getInsets().right + dimension.width, getInsets().top + getInsets().bottom + dimension.height);
        Component components[] = getComponents();
        for (Component component : components) {
            Point point = component.getLocation();
            point.translate(getInsets().left, getInsets().top);
            component.setLocation(point);
        }
        componentsAdjusted = true;
    }