I want to set an image icon in a panel.I am trying to do like this ;
JLabel label = new JLabel(new ImageIcon("logo.jpg"))
panelHeader.add(label);
add(panelHeader);
But the image is not showing.Any suggestion what i am doing wrong?
The new ImageIcon() constructor just creates an uninitialized image icon. You must invoke the createImageIcon() method that returns ImageIcon source to assign to your also created ImageIcon object.
ImageIcon icon = createImageIcon("logo.jpg", "my logo");
JLabel label = new JLabel(icon);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With