Here you can find the source of createOverlayIcon(Icon baseIcon, ImageIcon overlayIcon)
public static ImageIcon createOverlayIcon(Icon baseIcon, ImageIcon overlayIcon)
//package com.java2s; //License from project: Open Source License import java.awt.Graphics2D; import java.awt.Image; import java.awt.image.BufferedImage; import javax.swing.Icon; import javax.swing.ImageIcon; public class Main { public static ImageIcon createOverlayIcon(Icon baseIcon, ImageIcon overlayIcon) { BufferedImage result = new BufferedImage(baseIcon.getIconWidth(), baseIcon.getIconHeight(), BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = result.createGraphics(); baseIcon.paintIcon(null, g2, 0, 0); Image overlay = overlayIcon.getImage(); int w = 12; int h = 12; int x = baseIcon.getIconWidth() - w; int y = baseIcon.getIconHeight() - h; g2.drawImage(overlay, x, y, x + w, y + w, 0, 0, overlayIcon.getIconWidth(), overlayIcon.getIconHeight(), null);//from w w w . j a v a 2 s. c o m g2.dispose(); return new ImageIcon(result); } }