void (Rectangle bounds) { JTextComponent c = getComponent(); Insets margin = ComponentUtil.getParentOfType((Class<? extends JComboBox>)JComboBox.class, (Component)c) != null || ComponentUtil.getParentOfType((Class<? extends JSpinner>)JSpinner.class, (Component)c) != null || ClientProperty.isTrue(c, "TextFieldWithoutMargins") ? JBInsets.emptyInsets() : getDefaultMargins(); JBInsets.removeFrom(bounds, c.getInsets()); JBInsets.removeFrom(bounds, margin); for (IconHolder holder : icons.values()) { int gap = holder.extension.getIconGap(); if (holder.extension.isIconBeforeText()) { int offset = holder.extension.getAfterIconOffset(); holder.bounds.x = bounds.x; int extensionWidth = holder.bounds.width + gap + offset; bounds.x += extensionWidth; bounds.width -= extensionWidth; margin.left += extensionWidth; } else { holder.bounds.x = bounds.x + bounds.width - holder.bounds.width; int extensionWidth = holder.bounds.width + gap; bounds.width -= extensionWidth; margin.right += extensionWidth; } int top = (bounds.height - holder.bounds.height) / 2; if (top > gap) { JTextComponent component = getComponent(); boolean multiline = component != null && !Boolean.TRUE.equals(component.getDocument().getProperty("filterNewlines")); if (multiline) top = gap; // do not center icon for multiline text fields } holder.bounds.y = bounds.y + top; } if (!Objects.equals(c.getMargin(), margin)) c.setMargin(margin); }