Hi guys,
i'm new here and i am new in java and using ECLIPSE.
So, very shortly. The problem is explained in the title.
In an applet my mini game looks like this: single Applet
As u can see, there are 4 images, witch i coded in this way (example of background image):
public URL url; public Image bg; public void init(){ ... try{ url = getDocumentBase(); } catch(Exception e){ } bg = getImage(url, "images / bg.png"); // i put there spaces cuz this site auto edits image patch. } public void paint(Graphics g){ g.fillRect(0, 0, getSize().width, getSize().height); g.drawImage(bg, 0, 0, this); ... super.paint(g); }
Everything looks just fine in an applet, as u can see in a picture above.
But when I run it in JFrame, it looks like this: Applet in JFrame (do not pay your attention in red circles)
0 images are draw, only simple colors that are set up...
I tried to use 'getCodeBase()' in getImage method instead of 'url', but then an applet w/ JFrame don't even start and errors appear.
Where is a problem? It looks like an applet in JFrame can't read where the images is, or smth like that...
My images are placed in src/images folder.
can't figure out what's wrong...
Should I use other image drawing methods?