LayeredIcon (@Nullable Icon icon, boolean disabled) { LayeredIcon layeredIcon = new LayeredIcon(2); layeredIcon.setIcon(EMPTY_ICON, 0); if (icon == null) { return layeredIcon; } int width = icon.getIconWidth(); int height = icon.getIconHeight(); int emptyIconWidth = EMPTY_ICON.getIconWidth(); int emptyIconHeight = EMPTY_ICON.getIconHeight(); if (width <= emptyIconWidth && height <= emptyIconHeight) { layeredIcon.setIcon(disabled && IconLoader.isGoodSize(icon) ? IconLoader.getDisabledIcon(icon) : icon, 1, (emptyIconWidth - width) / 2, (emptyIconHeight - height) / 2); } return layeredIcon; }