Search code examples
javaswinggifimageicon

Possible to layer ImageIcons?


I was wondering if it were possible to layer ImageIcons in Java. I will be working with GIF images, and will have a grid of ImageIcons representing the "background" of my JPane.

When a certain condition is true, I need to be able to add an image that has transparency on top of the other image.

Regards, Jack Hunt


Solution

  • yes that's possible and there are two correct ways

    1) if is there only one Image then put JLabel with Icon to the GlassPane

    2) use LayeredPane for <= Java6 (not Java7 user there is JLayer)