Why does the following code not work for loading images (in Java)?

Kavan

New member
i am trying to make a java application that imports images, and i use this code:
base = System.getProperty("user.dir");
evildumb = Toolkit.getDefaultToolkit().getImage(base+"\evildumb.gif");

there is a file in the directory that is called evildumb.gif, but it doesnt appear

when i try to import it like this, it works flawlessly:
evildumb = Toolkit.getDefaultToolkit().getImage ( "C:\Users\...the filepath which i will not show for security\FirstGame\bin\evildumb.gif" );

i tried to System.out.println both base+evildumb.gif and the direct filepath and they were identical

however, only using the direct filepath seems to work

this is for a java application i created that implements a java applet. when i run the applet solo, both ways work, but when i run it through the application (aka in a frame) only the filepath works

help please!
i am trying to make a java application that imports images, and i use this code:
base = System.getProperty("user.dir");
evildumb = Toolkit.getDefaultToolkit().getImage(base+"\evildumb.gif"

there is a file in the directory that is called evildumb.gif, but it doesnt appear

when i try to import it like this, it works flawlessly:
evildumb = Toolkit.getDefaultToolkit().getImage ( "C:\Users\...the filepath which i will not show for security\FirstGame\bin\evildumb.gif" );

i tried to System.out.println both base+evildumb.gif and the direct filepath and they were identical

however, only using the direct filepath seems to work

this is for a java application i created that implements a java applet. when i run the applet solo, both ways work, but when i run it through the application (aka in a frame) only the filepath works

help please!
woops i tried to edit the details not add new ones...sorry
Solution found

wow, i found an interesting solution....what happens is that when i run it as an applet, the base is "FirstGame\bin" but when i run it in a frame (as application) the base is "FIrstgame\"

all fixed now...thank you
 
Back
Top