Creates a transparent icon. : Icon « Swing « Java Tutorial






import java.awt.image.BufferedImage;
import java.util.Arrays;
import javax.swing.Icon;
import javax.swing.ImageIcon;


public final class ImageUtils
{


  /**
   * Creates a transparent image.  These can be used for aligning menu items.
   *
   * @param width  the width.
   * @param height the height.
   * @return the created transparent image.
   */
  public static BufferedImage createTransparentImage (final int width, final int height)
  {
    return new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
  }

  /**
   * Creates a transparent icon. The Icon can be used for aligning menu items.
   *
   * @param width  the width of the new icon
   * @param height the height of the new icon
   * @return the created transparent icon.
   */
  public static Icon createTransparentIcon (final int width, final int height)
  {
    return new ImageIcon(createTransparentImage(width, height));
  }
}








14.116.Icon
14.116.1.Creating an Icon(implement Icon interface)
14.116.2.State-Aware Icon DefinitionState-Aware Icon Definition
14.116.3.implements Icon, SwingConstants
14.116.4.Demonstrate the loading of image files into icons for use in a Swing user interface
14.116.5.An empty icon with arbitrary width and height.
14.116.6.An icon for painting a square swatch of a specified Color.
14.116.7.Arrow Icon
14.116.8.Creates a transparent icon.
14.116.9.Layered Icon