[SOLVED] PictureViewer applet
Hello I have build a PictureViewer applet that shows an image, But it doesn't work, I only see a very small square that is a few pixel width en high.
I just don't understand why it is not working.
PictureViewer.java:
Code:
import java.awt.*;
import javax.swing.*;
import java.net.*;
import java.io.*;
import java.applet.*;
public class PictureViewer extends Applet {
Image img;
public void init(){
String pictureName = getParameter("pictureName");
img = getImage(getCodeBase(),pictureName);
showStatus("Loads" + pictureName);
MediaTracker mt = new MediaTracker(this);
mt.addImage(img,0);
try{mt.waitForID(0);}
catch(InterruptedException e){}
showStatus("Loading finished");
add(new ImagePanel(img));
setBackground(Color.white);
}
}
ImagePanel.java
Code:
import java.awt.*;
public class ImagePanel extends Panel {
private Image im;
public ImagePanel(Image img){
im = img;
setSize(im.getWidth(this),im.getHeight(this));
}
public void paint(Graphics g){
g.drawImage(im,0,0,this);
}
}
PictureViewer.html
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PictureViewer Applet</title>
</head>
<body>
<applet code= "PictureViewer.class" width="1020" height="900">
<param name="pictureName" value="Train.gif" />
</applet>
</body>
</html>
All the files are in the same map and the image Train.gif really exists.
Can someone help me?
thanks keffie91