Here you can find the source of getIcon(boolean isPressed, Icon baseIcon_)
public static Icon getIcon(boolean isPressed, Icon baseIcon_)
//package com.java2s; //License from project: Open Source License import java.awt.Color; import java.awt.Graphics; import java.awt.image.BufferedImage; import javax.swing.Icon; import javax.swing.ImageIcon; import javax.swing.JComponent; import javax.swing.JLabel; public class Main { private static final JComponent TEMP = new JLabel(); public static Icon getIcon(boolean isPressed, Icon baseIcon_) { BufferedImage img = new BufferedImage(baseIcon_.getIconWidth(), baseIcon_.getIconHeight(), BufferedImage.TYPE_INT_ARGB); Graphics g = img.getGraphics(); baseIcon_.paintIcon(TEMP, g, 0, 0); g.dispose();/*from ww w. ja va 2 s. c o m*/ for (int i = 0; i < img.getWidth(); i++) { for (int j = 0; j < img.getHeight(); j++) { Color rgba = new Color(img.getRGB(i, j), true); int alpha = rgba.getAlpha(); if (isPressed) { rgba = rgba.darker(); } else { rgba = rgba.brighter(); } rgba = new Color(rgba.getRed(), rgba.getGreen(), rgba.getBlue(), alpha); img.setRGB(i, j, rgba.getRGB()); } } return new ImageIcon(img); } }