Topic: how to show image?

  Print this page

1.how to show image? Copy to clipboard
Posted by: eliuhy
Posted on: 2003-03-13 19:38

//<html>
//<applet code=DrawPhoto.class width=500 height=500>
//</applet>
//</html>

import javax.swing.*;
import java.awt.*;
import java.applet.Applet;

//
public class DrawPhoto extends JApplet{
//
Image image;

public void init(){

image =getImage(getDocumentBase(),"t.gif");
}

//
public void paint(Graphics g){

g.drawImage(image,0,0,this);
}

}
//
t.gif with code same directory ,but can't show image!

2.Re:how to show image? [Re: eliuhy] Copy to clipboard
Posted by: cn
Posted on: 2003-03-14 20:09

你的图像一定是受保护的图片,换一张自己的图片

3.Re:how to show image? [Re: eliuhy] Copy to clipboard
Posted by: samx
Posted on: 2003-03-18 08:59

我试过用appletviewer 和 IE 都能正常显示图片。但若使用《Think in Java》中的方法,加入main()方法后,会出现Runtime Exception。我认为原因是:getImage()只能用在applet小程序中,而不可以在application 中使用。个人观点,仅供参考。

4.Re:how to show image? [Re: samx] Copy to clipboard
Posted by: snowbug
Posted on: 2003-03-18 12:16

samx wrote:
我试过用appletviewer 和 IE 都能正常显示图片。但若使用《Think in Java》中的方法,加入main()方法后,会出现Runtime Exception。我认为原因是:getImage()只能用在applet小程序中,而不可以在application 中使用。个人观点,仅供参考。

If you look at the API, the getImage() method is defined in the Applet class. Applet needs to be initialized by the browser before it can be used. When you run it from main(), the applet is not initialized and therefore a runtime exception is generated.

5.Re:how to show image? [Re: eliuhy] Copy to clipboard
Posted by: ccic134302
Posted on: 2003-03-18 15:58

在application中用toolkit类来调用图片


   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