import java.awt.*;
import java.applet.*;
import java.awt.image.*;
public class SerialImage extends Applet implements Runnable
{
int AppletWidth,AppletHeight,currentImage;
Image Animation[],SerialImage,OffScreen;
Thread newThread;
Graphics drawOffScreen;
MediaTracker MT;
ImageProducer Source;
CropImageFilter CutImage;
public void init()
{
MT = new MediaTracker(this);
Animation = new Image[8];
currentImage = 0;
AppletWidth = getSize().width;
AppletHeight = getSize().height;
OffScreen = createImage(AppletWidth,AppletHeight);
drawOffScreen = OffScreen.getGraphics();
SerialImage = getImage(getDocumentBase(),"run.gif");
MT.addImage(SerialImage,0);
try
{
showStatus("图像载入中...");
MT.waitForAll();
this.setBackground(Color.blue);
}
catch(InterruptedException E)
{
E.printStackTrace();
}
Source = SerialImage.getSource();
for(int i=0;i<8;i++)
{
CutImage = new CropImageFilter(i*128+3,0,128,141);
Animation[i]
= createImage(new FilteredImageSource(Source,CutImage));
drawOffScreen.drawImage(Animation[i],0,0,this);
}
}
public void start()
{
newThread = new Thread(this);
newThread.start();
}
public void stop()
{
newThread = null;
}
public void paint(Graphics g)
{
drawOffScreen.setColor(Color.blue);
drawOffScreen.fillOval(0,0,AppletWidth,AppletHeight);
drawOffScreen.drawImage(Animation[currentImage],0,0,this);
g.drawImage(OffScreen,0,0,this);
}
public void update(Graphics g)
{
paint(g);
}
public void run()
{
while(newThread != null)
{
repaint();
try
{
Thread.sleep(100);
}
catch(InterruptedException E){ }
currentImage = (++currentImage) % 8;
}
}
}
又一个简单的java applet图像移动重画实例
5星 · 超过95%的资源 需积分: 10 180 浏览量
2009-02-17
09:50:29
上传
评论 1
收藏 51KB RAR 举报
fjfhfn
- 粉丝: 1
- 资源: 6
最新资源
- 基于MATLAB的钢板表面缺陷检测系统
- MS SQL里生成行政区域县区信息表和相应数据
- delphi实现DBGrid全选和反选功能
- 25C11F41-2B2A-4D1A-AAA8-7C654526B129.pdf
- Android Studio Jellyfish(android-studio-2023.3.1.18-cros.deb)
- MVC+EF框架+EasyUI实现权限管理源码程序
- python第66-75天,Day66-75.rar
- python后端服务project-of-tornado.rar
- python测验,hello-tornado.rar
- 基于SpringBoot+Vue3快速开发平台、自研工作流引擎源码设计.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈