在线报名 | 加入收藏 | 学校地图

电话:400-0379-707 QQ:710034203

首页 > 学习园地 > 技术教程 > 正文阅读

洛阳北大青鸟:如何在网页中实现动画?

发布时间:2012-11-14 16:41:50 点击:0
洛阳北大青鸟导读:Animating an Array of Images in an Applet This is the simplest applet to animate an array of images.import java.applet.*;import java.awt.*;public class AnimApplet extendsApp...

Animating an Array of Images in an Applet This is the simplest applet to animate an array of images.
import java.applet.*;

import java.awt.*;

 

 

public class AnimApplet extends
Applet implements Runnable {
Image[] images = new Image[2];
int frame = 0;
Thread thread;

 

 

public void init() {
images[0] = getImage(getDocumentBase(),
"http://hostname/image0.gif");
images[1] = getImage(getDocumentBase(),
"http://hostname/image1.gif");
}
public void start() {
(thread = new Thread(this)).start();
}
public void stop() {
thread = null;
}
public void paint(Graphics g) {
g.drawImage(images[frame], 0, 0, this);
}
public void run() {
int delay = 1000; // 1 second
try {
while (thread == Thread.currentThread()) {
frame = (frame+1)%images.length;
repaint();
Thread.sleep(delay);
}
} catch (Exception e) {
}
}
}

热词搜索:
分享该网页到:   转播到腾讯微博  分享到QQ空间
  • ①理论课
  • ②上机课
  • ③职业导向训练(COT)
  • ④指导学习课(DLC)
  • ⑤项目案例课
  • ⑥在线培训课(OLTL)
  • ⑦阶段项目课
  • ⑧毕业设计课
人才招聘 | 视频专区 | 专题活动 | 认证查询 | 网站地图