I've written a Snake clone in the process of learning how to program in Java. It is an applet that uses images (loaded in the init() method using getImage(getDocumentBase(), "gfx/image.png");
When I run the applet in my IDE (Eclipse) it runs fine and all the images are shown.
My goal however is to create an executable jar file that I can pass around easier than an applet. So I created a new class and used a JPanel to host my applet. Now the problem is that getDocumentBase() always returns null, resulting in the images not being found on the filesystem, resulting in an empty screen.
I know the game runs cause I can navigate all the menus and see all the text that is printed. It's just the images that aren't loaded.
Is there any way around this? Should I load my images another way?
Thanks