GridBag (@Nullable Insets insets) { if (insets != null && (insets.top < 0 || insets.bottom < 0 || insets.left < 0 || insets.right < 0)) { Insets def = getDefaultInsets(gridx); insets = (Insets)insets.clone(); if (insets.top < 0) insets.top = def == null ? 0 : def.top; if (insets.left < 0) insets.left = def == null ? 0 : def.left; if (insets.bottom < 0) insets.bottom = def == null ? 0 : def.bottom; if (insets.right < 0) insets.right = def == null ? 0 : def.right; } this.insets = insets; return this; }