import java.awt.*;
import javax.swing.*;
public class FeiJi extends JApplet implements Runnable{
Image image;
int x,y;
public void init(){
x=0;
y=100;
image=this.getImage(this.getCodeBase(),"9.gif");
play(this.getCodeBase(),"1.mid");
this.setBackground(Color.red);
new Thread(this).start();

}
public void paint(Graphics g){
g.clearRect(0,0,this.getWidth(),this.getHeight());
x+=5;
if(x>this.getWidth()) x=0;
g.drawImage(image,x,y,this);
}
   public  void run(){
    while(true){
    try{
    Thread.sleep(100);
    }catch(Exception e){} 
    repaint();
    }
   }
}我想制作一个动态的图片以及播放音乐
我的编译通过了  但是运行不了 
运行的错误是
Exception in thread "main" java.lang.NoSuchMethodError: main
Press any key to continue...


解决方案 »

  1.   

    定义一个main方法就可以运行了
      

  2.   

    不是说JApplet不能有MAIN();
    为什么 我写上了还能编译通过
    但是还是不能显示
       我的工具是 JCREATOR
    我以前用ECLIPS 能运行
     ECLIPS 好象不需要什么网页就能直接显示了
      

  3.   

    我用JCREATOR 该怎么运行这个程序啊
     我不知道怎么用网页来运行  谢谢各位大哥大姐
      
      

  4.   

    <body>
    <center>
    <applet code=CalendarApplet.class width=360 height=320>
    </applet>
    </center>
    </body>将你写的类 编译后放在上面给的位置就可以了
      

  5.   

    用JAVA提供的APPLET 就可以了