用html页面可以正常显示,但在Eclipse中不能显示

c87087223 c87087223 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
在eclipse中工程目录在G:\JavaWorkplace\里面
新建了一个Lession9的工程,源代码如下:
package lession9;

import java.awt.Graphics;
import java.awt.Image;
import java.applet.*;
public class ImageTest extends Applet
{
private Image[] imgs;
private int totalImages=10;
private int currentImage;
private int j=0;

public void init() {
//img=getImage(getDocumentBase(),"T1.gif");
imgs=new Image[totalImages];
for (int i = 0; i < totalImages; i++) {
imgs[i]=getImage(getDocumentBase(),"T"+(i+1)+".gif");
}
}

public void paint(Graphics g) {
// TODO Auto-generated method stub
System.out.println(j++);
g.drawImage(imgs[currentImage], 0, 30, this);
currentImage=++currentImage%10;
try {
Thread.sleep(500);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
repaint();
}

public void start() {
currentImage=0;
}

}
然后在G:\JavaWorkplace\Lession9\src中新建ImageTest.html
内容如下:
<applet code="lession9.ImageTest.class" width=600 height=400>
</applet>

G:\JavaWorkplace\Lession9\src 里面有T1.gif~T10.gif10幅图片(G:\JavaWorkplace\Lession9\src\lession9中有ImageTest.class)
双击打开ImageTest.html,正常显示图片,但在eclipse中直接运行,显示不了,将图片放在G:\JavaWorkplace\Lession9\src\lession9也不能显示,大虾们教教我吧...
...全文
评论 3
收藏 已收藏
分享
返回顶部
c87087223
Eclipse 58,439 成员 49,457 内容