Icon () { // Check cached value first if(mySmallIcon != null){ return myIcon; } // [vova] It's safe to cast to ImageIcon here because all icons loaded by IconLoader // are ImageIcon(s). final Icon icon = getIcon(); if (icon instanceof ImageIcon imageIcon) { mySmallIcon = new MySmallIcon(imageIcon.getImage()); } else { mySmallIcon = icon; } return mySmallIcon; }