Topic: java applet编程显示图像---请问程序错在哪里?

  Print this page

1.java applet编程显示图像---请问程序错在哪里? Copy to clipboard
Posted by: clqtiger
Posted on: 2006-03-09 23:40

请高手看看下面这段程序是用来显示图像的,问题出在哪里?

import java.awt.*;
import java.applet.*;
public class ShowImage extends Applet
{ Image picture;
public void init()
{
  picture=getImage(getCodeBase(),"image.gif");
}
public void paint(Graphics g)
{
  g.drawImage(picture,0,0,this);
}
}

2.Re:java applet编程显示图像---请问程序错在哪里? [Re: clqtiger] Copy to clipboard
Posted by: Skybus
Posted on: 2006-03-10 10:53

you should look up tha java api about javax.imageio.*;before you start!

import java.awt.*;
import java.applet.*;
import java.io.*;
import javax.imageio.*;

public class ShowImage extends Applet {

public void init() {
try {
picture = ImageIO.read(new File("image.gif"));
picture = getImage(getCodeBase(), "image.gif");
} catch (IOException e) {
e.printStackTrace();
}
}

public void paint(Graphics g){

g.drawImage(picture,0,0,null);
}
private Image picture;
}

3.Re:java applet编程显示图像---请问程序错在哪里? [Re: clqtiger] Copy to clipboard
Posted by: east123
Posted on: 2006-03-14 09:40

我怎么感觉两种方法都可以啊,下面这种用gif图片时卡得

4.Re:java applet编程显示图像---请问程序错在哪里? [Re: clqtiger] Copy to clipboard
Posted by: zym
Posted on: 2006-03-18 09:41

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

public class ShowImage extends Applet{

public void paint(Graphics g){
Image picture=getImage(getCodeBase(),"image.gif");
g.drawImage(picture,0,0,this);
}
}


   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