Here you can find the source of createIcon(ImageIcon icon, ImageFilter filter)
private static synchronized ImageIcon createIcon(ImageIcon icon, ImageFilter filter)
//package com.java2s; // The contents of this file are subject to the Mozilla Public License Version import java.awt.Image; import java.awt.MediaTracker; import java.awt.Toolkit; import java.awt.image.FilteredImageSource; import java.awt.image.ImageFilter; import java.awt.image.ImageProducer; import javax.swing.ImageIcon; import javax.swing.JPanel; public class Main { /** Create a new icon which is filtered by some ImageFilter */ private static synchronized ImageIcon createIcon(ImageIcon icon, ImageFilter filter) { ImageProducer ip;//from ww w . j a v a2 s . c o m Image image; MediaTracker tracker; ip = new FilteredImageSource(icon.getImage().getSource(), filter); image = Toolkit.getDefaultToolkit().createImage(ip); tracker = new MediaTracker(new JPanel()); tracker.addImage(image, 1); try { tracker.waitForID(1); } catch (InterruptedException e) { e.printStackTrace(); return null; } return new ImageIcon(image); } }