I dont know why I cant add image to my JPanel
i use code:
class PanelGlowny extends JPanel {
private JLabel adam;
private JButton henryk;
PanelGlowny(){
this.setLayout(new BorderLayout());
ImageIcon imageurl = new ImageIcon("logo.jpg");
//Image img = imageurl.getImage();
adam = new JLabel(imageurl);
add(adam, BorderLayout.NORTH);
henryk = new JButton();
add(henryk, BorderLayout.CENTER);
}
}
Image is in the same folder as class, but if I use url to image it also do not add anything.
This code adding button, but do not add image 🙁
The problem is probably with my JDE, or Sandbox or sth like this, because code should be fine.
Try this:
Check How to Use Icons tutorial.
EDIT: loading remote image
Try that to load your image from web: