/* Main.java
 *
 * Created on 2006年11月30日, 下午7:13
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */package javaapplication1;
import java.applet.*;
import java.awt.*;/**
 *
 * @author gerc
 */
public class Main extends Applet{
    private String str;
    /** Creates a new instance of Main */
    public Main() {
    }
    public void paint(Graphics g)
    {
        g.drawLine(12,50,90,100);
        g.drawString(str,90,200);
    }
    /**
     * @param args the command line arguments
     */    public void init()
    {
        str="Let's Begin the exciting tourial";
    }
    
    
}然后再Index.html有这样的调用<htm>
<title>This is a test</title>
<body><Applet code="Main.class",width=200,height=600></Applet></body>
</htm>这么加载失败了?

解决方案 »

  1.   

    /*
     * NewJApplet.java
     *
     * Created on 2006年12月2日, 上午10:53
     *
     * To change this template, choose Tools | Template Manager
     * and open the template in the editor.
     *//**
     *
     * @author BluePower
     *
     */
    import java.awt.Graphics;
    import java.awt.Image;
    import java.awt.image.ImageObserver;
    import java.awt.image.ImageProducer;
    public class NewJApplet extends javax.swing.JApplet {
        
        /** Creates a new instance of NewJApplet */
        String str;
        public NewJApplet() {
        }
        public void paint(Graphics g)
        {
            Image img;
            g.drawLine(20,50,90,100);
            
            img=getImage(getCodeBase(),"d:\\image.JPG");
            g.drawImage(img,0,0,this);
        }
        
        public void init()
        {
            str="Hello go on,baby";
        }
    }为什么显示不出图象来,我是用NETBEANS的APPLETVIEWER调试的