Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java SE 综合讨论区  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 为何Applet在此装载不了图片?
chuxueaihaozhe





发贴: 26
积分: 0
于 2005-08-26 16:51 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
import java.awt.*;
import java.applet.Applet;
import javax.swing.*;

public class Pintu1 extends Applet
{
final int IMAGE_WIDTH = 120;
final int IMAGE_HEIGHT= 120;
final int NO_IMAGE = -1;
int m_nImageNo[][] ;
final int DELTAX = 120;
Image[] m_image = new Image[9];
Image m_imagAll ;

public void initData()
{
for(int i= 0;i<3;i++)
{
for(int j=0;j<3;j++)
{
m_nImageNo[i][j]=j*3+i;
}
}
m_nImageNo[1][2]=NO_IMAGE;
m_nImageNo[1][1]=7;
}

public void init()
{
MediaTracker mediaTracker = new MediaTracker(this);
m_imagAll = getImage(getCodeBase(),"pintu.JPG");
mediaTracker.addImage(m_imagAll,0);
try
{
mediaTracker.waitForAll();
}
catch(Exception e)
{
System.out.println("图片装载出错");
}

for(int i=0;i<9;i++)
{
m_image[i] = createImage(IMAGE_WIDTH,IMAGE_HEIGHT);
m_image[i] = getImage(getCodeBase(),i+".JPG");
Graphics g = m_image[i].getGraphics();
mediaTracker.addImage(m_image[i],i+1);

try
{
mediaTracker.waitForAll();
}
catch(Exception e)
{
System.out.println("图片装载出错");
}
initData();
}
}

public void paint(Graphics g)
{
g.setColor(Color.blue);
for(int i = 0;i<3;i++)
{
for(int j = 0;j<3;j++)
{
int x =i*IMAGE_WIDTH + DELTAX;
int y =j*IMAGE_HEIGHT;
if(m_nImageNo[i][j] == NO_IMAGE)
g.fill3DRect(x,y,IMAGE_WIDTH,IMAGE_HEIGHT,true);
else
{
g.drawImage(m_image[m_nImageNo[i][j]],x,y,this);
}
}
}
for(int i=0;i<3;i++)
{
int nRow = i%3;
int nCol = i/3;
g.drawImage(m_imagAll,0,0,IMAGE_WIDTH,IMAGE_HEIGHT,
nRow*IMAGE_WIDTH,nCol*IMAGE_HEIGHT,
(nRow+1)*IMAGE_WIDTH,(nCol+1)*IMAGE_HEIGHT,this);
}
}

public Pintu1()
{};

}
================================
<HTML>
<heard>

</heard>
<body>

<applet code ="Pintu1.class" width="480" height="360">
</applet>
</body>
</HTML>
=========================
请网友帮帮忙,看是什么原因.谢谢!




Hibernate开发指南

话题树型展开
人气 标题 作者 字数 发贴时间
8272 为何Applet在此装载不了图片? chuxueaihaozhe 2133 2005-08-26 16:51
7125 Re:为何Applet在此装载不了图片? chuxueaihaozhe 0 2005-08-26 16:58
6893 Re:为何Applet在此装载不了图片? chuxueaihaozhe 0 2005-08-26 17:02
7104 Re:为何Applet在此装载不了图片? chuxueaihaozhe 36 2005-08-26 19:26
7053 Re:为何Applet在此装载不了图片? chuxueaihaozhe 0 2005-08-26 16:59
7016 Re:为何Applet在此装载不了图片? chuxueaihaozhe 0 2005-08-26 17:00
7021 Re:为何Applet在此装载不了图片? chuxueaihaozhe 0 2005-08-26 17:00
7034 Re:为何Applet在此装载不了图片? chuxueaihaozhe 0 2005-08-26 17:00
6866 Re:为何Applet在此装载不了图片? chuxueaihaozhe 0 2005-08-26 17:01
7033 Re:为何Applet在此装载不了图片? chuxueaihaozhe 0 2005-08-26 17:01
6885 Re:为何Applet在此装载不了图片? chuxueaihaozhe 0 2005-08-26 17:01
6904 Re:为何Applet在此装载不了图片? chuxueaihaozhe 0 2005-08-26 17:01

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   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