Here is a simple applet to try loading an image but it shows a blank window
import java.applet.*;
import java.awt.*;
public class Mama extends Applet {
int width, height;
Image img;
@Override
public void init(){
img = getImage(getCodeBase(), "C:\\Users\\......\\Backgound.png");
}
@Override
public void paint(Graphics g){
g.drawImage(img, 0, 0, this);
}
}
I copied the path of the image from the directory, what am I doing wrong?
Unless they are signed, applets can only read files from the same location from which they were loaded. Move the image to image to a location that is accessible relative to the class (or document) path and use: