LayeredIcon () { return new LayeredIcon(2) { @Override public int getIconWidth() { int iconWidth = super.getIconWidth(); int tabWidth = TabLabel.this.getWidth(); int minTabWidth = JBUI.scale(MIN_WIDTH_TO_CROP_ICON); if (isCompressionEnabled && tabWidth < minTabWidth) { return Math.max(iconWidth - (minTabWidth - tabWidth), iconWidth / 2); } else { return iconWidth; } } @Override public void paintIcon(Component c, Graphics g, int x, int y) { Graphics g2 = g.create(x, y, getIconWidth(), getIconHeight()); try { super.paintIcon(c, g2, 0, 0); } finally { g2.dispose(); } } }; }