I am trying to add an image to my applet. I have googled this but I have not found a decent example that I understand. Does anyone know where I can find a good example of adding an image to and applet?
I got this online but when I run the applet it doesn't display my image.
public class Lab5 extends JApplet {
//Lab5(){}
Image img;
public void init() {
img = getImage(getDocumentBase(), "img\flag0.gif");
}
public void paintComponent(Graphics g) {
g.drawImage(img, 50, 50, this);
}
}
Below is my HTML file
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<applet code="Lab5.class" width= 250 height = 50></applet>
</body>
</html>