javaimageswingjlabelimageicon

Java image not showing?


Having a issue trying to display my logo. The picture is saved in the same folder as main.java

    ImageIcon im = new ImageIcon("banner.png"); 
    JLabel bam = new JLabel(im); 

    grid.add(bam);

Is there a problem in my syntax?


Solution

  • Try ImageIcon im = new ImageIcon(new File("banner.png")); If you're using eclipse, put it in the root folder, not the src folder. The root folder has the src folder and the bin folder.