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) {
}
}
}
Related Examples |
e558. 在Applet中多图片交互显示的更多相关文章
- PHP 读取文件夹(比如某共享文件夹)中的图片并显示
1.获取文件夹下图片public function albumList(){ $share_url = input('path'); $files = getImgList($share_url); ...
- GDI+中GIF图片的显示
某位网友曾经问过我GDI+中Gif图像显示的问题,一直没时间给你写,在此致歉.我把这篇文章送给他. 一.GIF格式介绍 1.概述 GIF(Graphics Interchange Format,图形交 ...
- winfrom向窗体中拖放图片并显示
首先要设置窗体的AllowDrop属性为true.然后在窗体的DragEnter事件中添加如下代码:调用自定义的显示图片的方法. #region "在用鼠标将某项拖放到区域时事件" ...
- 从npz文件中读取图片并显示的小例子
前提:我把自己的数据集存成了npz的形式,也就是npy的压缩形式.如果电脑上安装了解压软件,双击npz文件的话,会出现每一部分压缩文件的名字例如npz文件的名称为:mnist.npz文件,用好压解压软 ...
- Opencv中在图片上显示文本
1.cvPutText函数(在图像中加入文本) void cvPutText( CvArr* img, const char* text, CvPoint org, const CvFont* fon ...
- Vue.js项目中,当图片无法显示时则显示默认图片
使用require将图片进入,写法如下: data: () => ({logo: 'this.src="' + require('../assets/img.png') + '&quo ...
- HTML中使图片居中显示
注:imageId为图片id<style type="text/css"> #imageId{ display:block; position:relative; ma ...
- 用JSP从数据库中读取图片并显示在网页上
<1>先在mysql下建立如下的table. 并insert图像. mysql.sql文件如下: CREATE TABLE photo ( photo_no int(6) unsigned ...
- C# 图片保存到数据库和从数据库读取图片并显示
图片保存到数据库的方法: public void imgToDB(string sql) { //参数sql中要求保存的imge变量名称为@images //调 ...
随机推荐
- 如何发布Node模块到NPM社区
“学骑自行车最快的方式就是先骑上去” 一.安装node和npm 1.一种是通过编译node源文件安装node(注意:需要Python 2.6或2.7已经安装) $ wget http://nodejs ...
- [sh]uniq-sort-awk
题目:[百度搜狐面试题] 统计url出现次数 oldboy.log http://www.etiantain.org/index.html http://www.etiantain.org/1.htm ...
- 【Android】21.1 画板资源
分类:C#.Android.VS2015: 创建日期:2016-03-19 一.简介 画板资源(Drawable Resources)是用XML描述/Resources/drawable中的2D图形文 ...
- Mingw opencv Windows下命令行运行
1.下载opencv 2.3 http://sourceforge.net/projects/opencvlibrary/files/ 下个opencv-win版本吧 至于版本号就随意吧,我选的是2. ...
- yum 报错 Error: rpmdb open failed
# yum list rpmdb: unable to join the environment error: db3 error() from dbenv->open: Resource te ...
- javascript 图片上传缩略图预览
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="C ...
- js 三元表达式
JavaScript三元运算符的多种使用技巧 发现代码慢慢写多了的时候会不自觉的将if else 用 三元来替代,仅仅是未了让代码更简洁精辟,当然也有人说用三元可以让你有高潮的感觉.最近在写js 的时 ...
- VC++编程之道读书笔记(2)
第三篇 技术细节 第七章:细说开发人员必知必会的39个开发细节 细节36:单例模式的应用 在开发程序时,往往需要在整个工程中只需要一个类的实例.而这个实例一旦被创建就不能被其他的实例再创建了,通常我们 ...
- ajaxfileupload 半成品遇到的问题,不走success 走error的问题
大部分都是datatype 为 json的时候遇到的 1.遇到json被加pre标签 去掉 2.遇到json被加audio 标签 去掉 3.遇到json转换错误,换方式转 改后的代码如下 , 有注 ...
- RTX——第12章 系统时钟节拍和时间管理
以下内容转载自安富莱电子: http://forum.armfly.com/forum.php 本章节为大家讲解 RTX 操作系统的时钟节拍和时间管理函数,其中时间管理函数是 RTX 的基本函数,初学 ...