下面是一个Apple(程序,其功能是播放动画。要求根据给出的3幅图片设计1个动画。请改正程序中的错误(有下划线的语句),使程序能输出正确的结果。注意:不改动程序的结构,不得增行或删行。程序运行结果如下:import java.awt.*;import java.applet.*;import java.awt.image.*;/*<applet code="ex24_3.class" width=800 height=400 ></applet>*/public class ex24_3 extends Applet implements Runnable {Image[] images=new Image[4];Image image;int IMG nClick=over(this) title=放大Number=3;int currentImage=0;Thread thisThread;public void init(){for (int x=0;x<IMG nClick=over(this) title=放大Number;x++){images[x]= getImage(getCodeBase(),"IMG nClick=over(this) title=放大"+x+".gif");}image=images[0];}public void paint(Graphics g){g.drawImage(image[0],0,0,null);}public void update(Graphics g){paint(g);}public void start(){thisThread = new Thread(this);thisThread.start();}public void stop(){thisThread.stop();thisThread=null;}public void run(){while(true){currentImage++;currentImage=IMG nClick=over(this) title=放大Number;image=images[IMG nClick=over(this) title=放大Number];repaint();try{thisThread.sleep(100);}catch (Exception e){}}}}ex24_3, html<HTML><HEAD><TITLE>ex24_3</TITLE></HEAD><BODY><applet code="ex24_3.class" width=800 height=400 ></applet></BODY></HTML>
下面是一个Apple(程序,其功能是播放动画。要求根据给出的3幅图片设计1个动画。请改正程序中的错误(有下划线的语句),使程序能输出正确的结果。
注意:不改动程序的结构,不得增行或删行。
程序运行结果如下:
import java.awt.*;
import java.applet.*;
import java.awt.image.*;
/*
<applet code="ex24_3.class" width=800 height=400 >
</applet>
*/
public class ex24_3 extends Applet implements Runnable {
Image[] images=new Image[4];
Image image;
int IMG nClick=over(this) title=放大Number=3;
int currentImage=0;
Thread thisThread;
public void init(){
for (int x=0;x<IMG nClick=over(this) title=放大Number;x++){
images[x]= getImage(getCodeBase(),"IMG nClick=over(this) title=放大"+x+".gif");
}
image=images[0];
}
public void paint(Graphics g){
g.drawImage(image[0],0,0,null);
}
public void update(Graphics g){
paint(g);
}
public void start(){
thisThread = new Thread(this);
thisThread.start();
}
public void stop(){
thisThread.stop();
thisThread=null;
}
public void run(){
while(true){
currentImage++;
currentImage=IMG nClick=over(this) title=放大Number;
image=images[IMG nClick=over(this) title=放大Number];
repaint();
try{
thisThread.sleep(100);
}
catch (Exception e){}
}
}
}
ex24_3, html
<HTML>
<HEAD>
<TITLE>ex24_3</TITLE>
</HEAD>
<BODY>
<applet code="ex24_3.class" width=800 height=400 >
</applet>
</BODY>
</HTML>