When creating an ImageIcon in Java, is there a way to shorten the path to the file instead of having C:\Users\John\Documents\Images\image.gif could I just have the path be image.gif?
I have tried putting the image in the same directory as the Java class but it does not locate the image.
ImageIcon ii = new ImageIcon(Test.class.getResource("test.gif"));In this case, Test.class and test.gif are in the same location. Normally, you would structure it like so:
Set both src and resources as source folders. Then when you compile, test.gif will be outputted to the same location as Test.class.