Posted by Darryl Burke on August 22, 2010
These Alpha Icons wrap any Icon and paint it with the specified transparency. As Swing does not play well with an Icon that is not itself an ImageIcon but requires to show an animated GIF, two implementations are provided: AlphaIcon, which is good for wrapping any Icon, including an ImageIcon with a static image, and AlphaImageIcon which extends ImageIcon and can provide transparency for an ImageIcon that holds an animated image.
Each implementation provides a constructor that takes two parameters: the icon to be wrapped, and the opacity, a float value in the range 0.0F (fully transparent) to 1.0F (fully opaque).
When combined with Rob’s CompoundIcon with a Z_AXIS alignment, AlphaIcon and AlphaImageIcon allow you to overlay one Icon on another with the bottom Icon showing through. Multisort Table Header Cell Renderer showcases the use of AlphaIcons with varying transparency to indicate multiple sort orders in the header of a JTable.