I have two icons one is transparent so I need to add one icon and I have to add the transparent icon on top of that:
public static void main(String[] args) {
Icon icon = new ImageIcon("0.png");
Icon icon1 = new ImageIcon("2.png");
JLabel label = new JLabel();
label.setIcon(icon);
//label.setIcon(icon1);
JFrame frame = new JFrame();
frame.add(label, BorderLayout.CENTER);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
See Compound Icon. You can combine Icons along the X/Y/Z axis.
Please try this code:
This will do.
BufferedImage
for each of the icons.BufferedImage
(let us call itcombinedImage
) of the same size.combinedImage.createGraphics()
to get aGraphics2D
(call itg
) instance.g
.g
.g
.combinedImage
for the icon.E.G.