I am a new programmer and have just started using Eclipse. Previously, I used JGRASP and when I wanted to add an image to a button all I did was to create an Image
folder within the class's folder and write:
setIcon(newImageIcon(this.getClass().getResource("/Images/name.png")));
I tried the same thing with Eclipse but I get a main:NullPointerException
error.
I already read another post and added a source folder
to my project named Images
but nothing changed. The following is the code segment I have an issue with:
resetButton.setIcon(newImageIcon(this.getClass().getResource("/Images/helpIcon.png")));
You are on right way. You had added resource folder. This is the additional root for your resources. Here, in this folder (as root) you have to create /Image folder and then put files into it: