Reputation: 57
I have a window that looks like this: https://ibb.co/XZ6q43F
And I want to display a .png image above the current content. The final display should be like this (done with Paint): https://ibb.co/BzQH7V8
I tried this:
ImageIcon icone = new ImageIcon("images/redcross.png");
JLabel image = new JLabel(icone);
frame.add(image);
But this has no effect. Someone can help me ? thank you in advance
Upvotes: 0
Views: 63
Reputation: 324088
I want to display a .png image above the current content.
Use a Glass Pane
. A glass pane is painted over top of the entire frame. So you can add your image to the glass pane and then make the glass pane visible.
See the section from the Swing tutorial on How to Use Root Panes. The example just paints a dot so you should be able to modify it to draw your image.
Upvotes: 1