Here you can find the source of mergeIcons(ImageIcon bottom, ImageIcon top)
Parameter | Description |
---|---|
bottom | The Icon drawn at the bottom |
top | The Icon drawn at the top |
public static ImageIcon mergeIcons(ImageIcon bottom, ImageIcon top)
//package com.java2s; //License from project: Open Source License import javax.swing.*; import java.awt.*; import java.awt.image.BufferedImage; public class Main { /**/*from w w w. j a va 2 s.c o m*/ * Merge the two given icons in one, drawing {@code bottom} under {@code top}. * @param bottom The Icon drawn at the bottom * @param top The Icon drawn at the top * @return THe merged Icon. */ public static ImageIcon mergeIcons(ImageIcon bottom, ImageIcon top) { if (bottom == null) { return top; } if (top == null) { return bottom; } BufferedImage image = new BufferedImage(Math.max(bottom.getIconWidth(), top.getIconWidth()), Math.max(bottom.getIconHeight(), top.getIconHeight()), BufferedImage.TYPE_INT_ARGB); Graphics g = image.getGraphics(); g.drawImage(bottom.getImage(), 0, 0, null); g.drawImage(top.getImage(), 0, 0, null); return new ImageIcon(image); } }