void (Graphics g) { final Icon icon = myIsSelected? mySelectedIcon : myIcon; if (icon != null) { final Graphics2D g2 = (Graphics2D)g; g2.setBackground(getBackground()); final AffineTransform savedTransform = g2.getTransform(); g2.scale(((double)getWidth()) / icon.getIconWidth(), ((double)getHeight()) / icon.getIconHeight()); icon.paintIcon(this, g2, 0, 0); g2.setTransform(savedTransform); } super.paintComponent(g); }