import java.awt.*;  
import java.applet.*;  
import java.awt.image.*;  
import java.awt.image.ImageObserver;  
import java.net.URL;  
public class MyApplet extends Applet implements ImageObserver{  
 Image img;  
 String imgPath = "";  
 int xpoint = 100, ypoint = 100;  
 URL imgURL = getDocumentBase();
 
 public void init() {    setBackground(Color.white); 
  setForeground(Color.blue); 
  imgPath ="test.jpg"; 
  img = getImage(imgURL, imgPath);
}  public void paint(Graphics g) {  
   MediaTracker mt=new MediaTracker(this);
   mt.addImage(img,0);
   try{mt.waitForID(0);}catch(Exception e){}
   g.drawImage(img,xpoint,ypoint,img.getWidth(this),img.getHeight(this),this);

}

解决方案 »

  1.   

    你没有void main()当然不会出现!
      

  2.   

    奇怪怎么还是不行?
    这个是我的html文件,test.jpg和MyApplet在同一个目录。怎么还是出不来?
    <html>
    <head>
    <title>"MyApplet text"
    </title>
    <body>
    <applet code="MyApplet.class" width=800 height=600 /applet> 
    </body>
    </head>
    </html>
      

  3.   

    <applet code="MyApplet.class" codebase="." width=800 height=600></applet>