编译成class后
你需要一个html文件包含下面代码: <APPLET
   CODE=border.class
   WIDTH=200
   HEIGHT=200 >
</APPLER> 
浏览这个html

解决方案 »

  1.   

    applet程序是嵌在网页中运行的。用法如上
      

  2.   

    用appleviewer XX.java也不可以
      

  3.   

    of course 不可以,应该是
    appletviewer xx.htm(html)
    xx.class 嵌在htm中,象上面两层楼那位老兄写的。。
      

  4.   

    為什麼有的程式可以用appletviewer XX.java 看到結果呢??
      

  5.   

    html file and class file at the same path,
    好运与你同行
      

  6.   

    最好html文件与class文件在同一文件夹中
    你的程序没有问题,只是找不到*.class
    好运与你同行
      

  7.   

    你的程序在网页里可以看到,但是用appletviewer确实不行,奇怪
      

  8.   

    改成application也能运行。
    下面代码只是添加了main()函数。其他没动。
    import java.applet.Applet;
    import java.awt.*;
    import java.awt.event.*; /*
    <APPLET
       CODE=border.class
       WIDTH=200
       HEIGHT=200 >
    </APPLER> 
    */class textPanel extends Panel {
    TextField Text1;
    textPanel(){
    Text1=new TextField(30);
    add(Text1);
    }
    }public class border extends Applet implements ActionListener{
    Button button1,button2,button3,button4;
    textPanel Panel1; public void init(){
    setLayout(new BorderLayout());
    button1=new Button("1");
    add("North",button1);
    button1.addActionListener(this);
     
    button2=new Button("2");
    add("West",button2);
    button2.addActionListener(this); button3=new Button("3");
    add("South",button3);
    button3.addActionListener(this); button4=new Button("4");
    add("East",button4);
    button2.addActionListener(this);  Panel1=new textPanel();
    add("Center", Panel1);
    Panel1.Text1.setLocation(0,0);
    } public void actionPerformed(ActionEvent e){
    //Panel1.Text1.setText("Button"+((Button) e.getSource()).getLabel()+"clicked.");
    Object source = e.getSource();
    if (source == button4){
    this.destroy();
    }
    }    public static void main(String args[]) {
    border b = new border();
    b.init();
    b.start(); Frame f = new Frame("Border"); f.add("Center", b);
    f.setSize(300, 300);
    f.show();
        }}
      

  9.   

    <HTML>      
    <APPLET>
         CODE=border.class
         WIDTH=200
         HEIGHT=200 >
    </APPLET> 
    </HTML>
      

  10.   

    要不你可以自己编写一个main程序,在该程序里调用init()。
      

  11.   

    <APPLET
        CODE=border.class
        WIDTH=200
        HEIGHT=200 >
    </APPLER> <----*呵呵,您寫的都很對,就是有個地方打了個別字,是</APPLET>哦,再try吧