code: private void adjustBorderInsets() {
          Insets parentInsets = parent.getInsets();
  
          //  May need to adust the height of the parent component to fit
          //  the component in the Border
  
          if (edge == Edge.RIGHT || edge == Edge.LEFT) {
              int parentHeight = parent.getPreferredSize().height - parentInsets.top - parentInsets.bottom;
              int diff = component.getHeight() - parentHeight;
  
              if (diff > 0) {
                  int topDiff = (int) (diff * alignment);
                  int bottomDiff = diff - topDiff;
                  borderInsets.top += topDiff;
                  borderInsets.bottom += bottomDiff;
              }
          }
  
          //  May need to adust the width of the parent component to fit
          //  the component in the Border
  
          if (edge == Edge.TOP || edge == Edge.BOTTOM) {
              int parentWidth = parent.getPreferredSize().width - parentInsets.left - parentInsets.right;
              int diff = component.getWidth() - parentWidth;
  
              if (diff > 0) {
                  int leftDiff = (int) (diff * alignment);
                  int rightDiff = diff - leftDiff;
                  borderInsets.left += leftDiff;
                  borderInsets.right += rightDiff;
              }
          }
      }
docs: /*
  The complimentary edges of the Border may need to be adjusted to allow
  the component to fit completely in the bounds of the parent component.