code: public static Rectangle getInteriorRectangle(Component c, Border b, int x, int y, int width, int height) {
  
          final Insets insets;
          if (b != null) {
              insets = b.getBorderInsets(c);
          } else {
              insets = new Insets(0, 0, 0, 0);
          }
  
          return new Rectangle(x + insets.left, //
                  y + insets.top, //
                  width - insets.right - insets.left, //
                  height - insets.top - insets.bottom);
      }
docs: Gets the interior rectangle.
  
  @param c
  the target component.
  @param b
  the border.
  @param x
  the x coordinate.
  @param y
  the y coordinate.
  @param width
  the width.
  @param height
  the height.
  @return the rectangle.