Rectangle (final @NotNull JLabel label) { final Dimension size = label.getPreferredSize(); Icon icon = label.getIcon(); final Point point = new Point(0, 0); final Insets insets = label.getInsets(); if (icon != null) { if (label.getHorizontalTextPosition() == SwingConstants.TRAILING) { point.x += label.getIconTextGap(); point.x += icon.getIconWidth(); } else if (label.getHorizontalTextPosition() == SwingConstants.LEADING) { size.width -= icon.getIconWidth(); } } point.x += insets.left; point.y += insets.top; size.width -= point.x; size.width -= insets.right; size.height -= insets.bottom; return new Rectangle(point, size); }