📄 55.txt
字号:
//
案例:2307 Applet图像浏览器
案例文件:ImageTape.java/PictureSee.html
目 标:分析程序、确定传递给Applet各参数的作用;掌握Applet的图像处理功能。
配置说明:在发布ImageTape.class的目录下创建一个叫images的子目录,然后在里面放上要浏览的图片。
代 码:
/ * 范例名称:Applet图像浏览器
* 源文件名称:ImageTape.java/PictureSee.html
* 要 点:Applet中图像的载入、显示和刷新
*/
// 源文件ImageTape.java
import java.applet.Applet;
import java.awt.*;
public class ImageTape extends Applet
{
int num = 5;
Image imgs[];
public void init()
{
imgs = new Image[num];
for(int i = 0; i < num; i++)
{
imgs[i] = getImage(getDocumentBase(), "images/" +"t" + (i+1)+ ".gif");
}
this.setBackground(Color.white);
}
public void paint(Graphics g)
{
while(true)
{
for(int i=0;i<num;i++){
g.drawImage(imgs[i],0,0,this);
Thread t = new MyLater();
t.start();
try{
t.join();
}catch(InterruptedException e){
}
g.clearRect(0,0,this.getBounds().width,this.getBounds().height);
}
}
}
public class MyLater extends Thread{
public void run() {
try{
this.sleep(1000);
}catch(InterruptedException e){
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -