Hello Members,

I have a Class_A which extends a JPanel. This JPanel is inside of a JFrame. In Class_A, I have a series of images (stored in an ImageIcon array) and another image, let's call it Image_A, which is also a ImageIcon type. How do I make Image_A a background image for Class_A and also be able to show the series of images on top of this background?

If the above is not possible, can I make two classes (which extend from JPanel) and layer them on top of another and using the setOpaque(false) method?

I would be grateful for any help.

Thank you!

Hello Members,

Any comments/suggestions?

Thank you!

Well, all you need to do is paint on the panel.
So in the class that extends JPanel create the paintmethod

public void paintComponent(Graphics g) {
 Graphics2D g2d = (Graphics2D) g;

then simply draw onto the panel


this will draw the background image first, then draw everything else above it.

Hello Akill and Sean,

Thank you!!


Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.