编译通过,运行不了,怎么回事?如何改呢?
import java.awt.*;
import java.applet.*;
public class Botton1 extends Applet{
 Button b1=new Button("Button1");
 Button b2=new Button("Button2");
 public void init(){
 add(b1);
 add(b2);
 }
}

解决方案 »

  1.   

    你也可以用appletviewer这个命令运行试试!
      

  2.   

    Applet小程序不是使用java这个命令来运行 的啊.要放到网页中,或者appletviewer来运行
      

  3.   

    Applet是该那样执行,但是用java也可以执行吧,就选择Java Applet也是可以的,我以前弄过,用main()调用
      

  4.   

    Applet要放到html里运行<applet code="Botton1.class" width=600 height=400></applet>  当然你要不想放到html里或许也行, 自己写个main然后new 一个Frame,把Applet加进去,不过没这样试过
      

  5.   

    楼主,Applet中没有main()方法作为java解释器的入口,所以你必须编写HTML文件,把Applet嵌入其中,然后用appletviewer来运行,或者直接在支持java的浏览器上运行,HTML文件如下:<html>
    <head>
    <title>Applet</title>
    </head>
    <body><applet code=Botton1.class></applet></body>
    </html>然后保存为html文件,在命令行输入命令“appletviewer +html文件名”运行
    注:要把Botton1.java编译成Botton1.class文件,然后再把Botton1.class嵌套进html文件
      

  6.   

    我也出现过这样的问题 ,但是用Eclipse就没有问题。
      

  7.   

    不好意思,改正一下,<applet code=Botton1.class width=300 height=300></applet>//加上width,height