Topic: 如何加载web图像

  Print this page

1.如何加载web图像 Copy to clipboard
Posted by: 一枝梅
Posted on: 2005-05-12 17:35

import java.applet.*;
import java.awt.*;
import java.net.*;

public class ShowImage extends Applet {
Image image;
URL imagegur=null;
public void init(){

String url="http://img.eoshow.com/eoshow/cn/ni2.gif";
}
public void paint(Graphics g){
g.drawImage(image,30,10,this);
}
}
启动applet小程序为何是空白?

2.Re:如何加载web图像 [Re: 一枝梅] Copy to clipboard
Posted by: why
Posted on: 2005-05-12 21:20

What do you think it shouldn't be 空白?
Do you know what it is doing? NOTHING! Dead

3.Re:如何加载web图像 [Re: 一枝梅] Copy to clipboard
Posted by: 一枝梅
Posted on: 2005-05-13 08:24

运行如下ShowImage.html后为空白
<HTML>
<applet code=ShowImage.class width=300 height=120>
</applet>
</HTML>
不知错在哪里了,请指教

4.Re:如何加载web图像 [Re: 一枝梅] Copy to clipboard
Posted by: ljy0000
Posted on: 2005-05-13 09:54

在你的程序中,image对象未初始化,所以不会加载,应这样:
在paint方法的最前面加下列语句:
imagegur=new URL(url);
image=getImage(imagegur);

5.Re:如何加载web图像 [Re: ljy0000] Copy to clipboard
Posted by: why
Posted on: 2005-05-14 09:23

ljy0000 wrote:
在你的程序中,image对象未初始化,所以不会加载,应这样:
在paint方法的最前面加下列语句:
imagegur=new URL(url);
image=getImage(imagegur);


import java.applet.*;
import java.awt.*;
import java.net.*;

public class ShowImage extends Applet {
  Image image;

  URL imageUrl = null;

  public void init() {

    String url = "http://img.eoshow.com/eoshow/cn/ni2.gif";
    try {
      imageUrl = new URL(url);
    } catch (Exception e) {

    }
    image = getImage(imageUrl);

  }

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

6.Re:如何加载web图像 [Re: 一枝梅] Copy to clipboard
Posted by: 一枝梅
Posted on: 2005-05-17 08:53

奇怪,我按照上面做了,但还是不成功。
首先出现小程序已载入,稍后就出现启动:未初始化小程序。
就是没有所要加载的内容.

7.Re:如何加载web图像 [Re: 一枝梅] Copy to clipboard
Posted by: why
Posted on: 2005-05-17 09:16

How did you run this applet?

Using AppletViewer?
Failed with IE? Then try Mozilla.

J2SDK version? OS? ...
At least you have to describe your configuration.

Have you taken a look at 置顶索引???

8.Re:如何加载web图像 [Re: 一枝梅] Copy to clipboard
Posted by: 一枝梅
Posted on: 2005-05-17 15:12

appletviewer ShowImage.html
java 2 platform standard edition1.5.0

9.Re:如何加载web图像 [Re: 一枝梅] Copy to clipboard
Posted by: 一枝梅
Posted on: 2005-05-17 16:17

我安装了Mozilla过后,还是不行。
我怀疑是不是网络助手捣鬼,我已卸载它有几个月了,但时不时
出现屏蔽的提示,如何彻底根除它。

10.Re:如何加载web图像 [Re: 一枝梅] Copy to clipboard
Posted by: 一枝梅
Posted on: 2005-05-18 08:20

j2SE runtime environment 5.0 update 2

11.Re:如何加载web图像 [Re: 一枝梅] Copy to clipboard
Posted by: 一枝梅
Posted on: 2005-05-18 08:24

appletviewer ShowImage.html后出现如下提示:

java.security.AccessControlException: access denied (java.net.SocketPermission i
mg.eoshow.com resolve)
at java.security.AccessControlContext.checkPermission(AccessControlConte
xt.java:269)
at java.security.AccessController.checkPermission(AccessController.java:
401)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:524)
at java.lang.SecurityManager.checkConnect(SecurityManager.java:1023)
at sun.awt.image.URLImageSource.<init>(URLImageSource.java:41)
at sun.applet.AppletImageRef.reconstitute(AppletImageRef.java:33)
at sun.misc.Ref.get(Ref.java:46)
at sun.applet.AppletViewer.getCachedImage(AppletViewer.java:377)
at sun.applet.AppletViewer.getImage(AppletViewer.java:372)
at java.applet.Applet.getImage(Applet.java:236)
at ShowImage.init(ShowImage.java:18)
at sun.applet.AppletPanel.run(AppletPanel.java:353)
at java.lang.Thread.run(Thread.java:534)

12.Re:如何加载web图像 [Re: 一枝梅] Copy to clipboard
Posted by: ljy0000
Posted on: 2005-05-18 09:06

我的也出现了这种情况,从提示看,大约是因为图片access denied(拒绝存取),看来是由于Applet安全机制起作用的原因,大家有对这种情况了解的吗?

13.Re:如何加载web图像 [Re: 一枝梅] Copy to clipboard
Posted by: dengyinjun
Posted on: 2005-05-25 02:53

Applet是不能访问本地资源的~~~~~~~~~~

14.Re:如何加载web图像 [Re: 一枝梅] Copy to clipboard
Posted by: 一枝梅
Posted on: 2005-05-25 11:51

如何让它能够访问?


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923