能运行,但为什么我的程序不能显示图片?请指出错误,谢了
import java.applet.Applet;
import java.awt.*; public class Imager extends Applet
{
Image picture; boolean imageLoaded = false; public void init()
{
picture = getImage(getCodeBase(), "llk.gif"); // 装载图像
Image offScreenImage = createImage(this.getSize().width,
this.getSize().height);
Graphics offScreenGC = offScreenImage.getGraphics(); // 获取Graphics对象
offScreenGC.drawImage(picture, 0, 0, this); // 显示非屏幕图像
} public void paint(Graphics g)
{
if (imageLoaded)
{
g.drawImage(picture, 0, 0, null); // 显示图像,第四参数为null,不是this
showStatus("Done");
} else
showStatus("Loading image");
} public boolean imageUpdate(Image img, int infoflags, int x, int y, int w,
int h)
{
if (infoflags == ALLBITS)
{
imageLoaded = true;
repaint();
return false;
} else
return true;
}
}
import java.applet.Applet;
import java.awt.*; public class Imager extends Applet
{
Image picture; boolean imageLoaded = false; public void init()
{
picture = getImage(getCodeBase(), "llk.gif"); // 装载图像
Image offScreenImage = createImage(this.getSize().width,
this.getSize().height);
Graphics offScreenGC = offScreenImage.getGraphics(); // 获取Graphics对象
offScreenGC.drawImage(picture, 0, 0, this); // 显示非屏幕图像
} public void paint(Graphics g)
{
if (imageLoaded)
{
g.drawImage(picture, 0, 0, null); // 显示图像,第四参数为null,不是this
showStatus("Done");
} else
showStatus("Loading image");
} public boolean imageUpdate(Image img, int infoflags, int x, int y, int w,
int h)
{
if (infoflags == ALLBITS)
{
imageLoaded = true;
repaint();
return false;
} else
return true;
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货