I am trying to make a few different jpgs appear on a GUI I am working on. Originally, I was just referencing the file on my computer but I now want to put the jpgs into my project folder and reference them from there. I was looking up how to do this online and I have gotten this far:
BufferedImage myPicture = null;
try {
myPicture = ImageIO.read(getClass().getResource("/HIOLogo.jpg"));
} catch (IOException e1) {
e1.printStackTrace();
}
JLabel headerImage = new JLabel(new ImageIcon(myPicture));
headerImage.setBounds(0, 0, 200, 200);
this.add(headerImage);
}
However, I am not sure where I should be putting the HIOLogo.jpg file within my project? Right now I just dragged the file straight into the project folder. When I run this I get an IllegalArgumentException.