农村四月闲人少,勤学苦攻把名扬。这篇文章主要讲述e558. 在Applet中多图片交互显示相关的知识,希望能为你提供帮助。
This is the simplest applet to animate an array of images. In practice, you should use double-buffering (which this example does not use) to eliminate flickering.
import java.applet.*; import java.awt.*; public class AnimApplet extends Applet implements Runnable { Image[] images = new Image[2]; int frame = 0; volatile 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) { } } }
【e558. 在Applet中多图片交互显示】
Related Examples |
推荐阅读
- Unity输出PC端(Windows) 拖拽文件到app中
- e552. 取Applet的参数
- SVG g元素用法详解
- SVG教程入门介绍
- SVG第一个例子详解
- Struts 2项目(登录和注销示例)
- Struts 2提取表的所有记录示例
- Struts 2 i18n用法示例图解教程
- Struts 2 Tiles Framework集成教程示例