java Applet 小程序 的图片无法在网页上显示

幻雪 2010-06-12 01:13:59
我的这个程序,可以用appletviewer在dos下运行,但是写成html之后就无法看到图片,请教~

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

//package showposition;


import java.awt.Graphics;
import java.awt.Image;
import javax.swing.JApplet;

/**
*
* @author Administrator
*/
public class ShowPosition extends JApplet {

/**
* Initialization method that will be called after the applet is loaded
* into the browser.
*/
private Image image;

public void init() {
// TODO start asynchronous download of heavy resources
System.out.println("base:"+getDocumentBase());
image = getImage(getDocumentBase(),"map.JPG");
}


public void paint(Graphics g){
g.drawImage(image, 0, 0,this);
}

// TODO overwrite start(), stop() and destroy() methods

}



同级目录下html代码:

<html>
<applet code = ShowPosition.class width = 260 height = 150>
</applet>
</html>


map.jpg也在同级目录下~!
...全文
182 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
幻雪 2010-06-12
  • 打赏
  • 举报
回复
不可能是引用的问题
因为在appletviewer下可以正常运行,现在已经不是图片可不可以显示的问题了
而是applet在浏览器下不能运行,我发现问题在于jre中javacpl->高级->浏览器的默认java的设置有问题
正常情况下,是会选中Microsoft Internet explorer的,但是我的没有选中,而且在改的时候,他说我权限不够
改不了~!
请问怎么解决啊??
luiganqian 2010-06-12
  • 打赏
  • 举报
回复
路过 帮顶!!
poorBing 2010-06-12
  • 打赏
  • 举报
回复
老早以前写过,是不是html里的引用由问题啊

62,616

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧