类别: 计算机和互联网
publicclassDynGifLabel扩展了JLabelimplementsRunnable {
privatestaticfinallongserialVersionUID = 45345345355L;
//要存储Gif动态图片
publicImageimage;
//要刷新绘画功能
ThreadrefreshThread;
publicDynGifLabel(Imageimage){
this.image =图片;
refreshThread = newThread(this);
refreshThread.start();
}
publicvoidpaint(Graphicsg){
super.paint(g);
Graphics2Dgraph =(Graphics2D)g;
如果(图像!=空){
//全屏绘制图片
graph.drawImage(图像swing 动图,0,0,getWidth(),getHeight()swing 动图,0,0,图像
.getWidth(null),image.getHeight(null),null);
}
}
publicvoidrun(){
while(true){
this.repaint(); //在这里叫油漆
尝试{
Thread.sleep(100); //睡眠100毫秒
}捕获(例外){
e.printStackTrace();
}
}
}
}
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-155156-1.html