import java.applet.Applet;
import javax.swing.JLabel;
import javax.swing.ImageIcon;public class Applet1 extends Applet {
public Applet1() {
}public void init() {
JLabel label = new JLabel(new ImageIcon(getImage(getCodeBase(),"icon.gif")));
//getCodeBase()将得到你页面文件所在的绝对路径,这很关键,如果你的图片方在和页面相同的位置,这样就可以了。
this.add(label);
}}<------ 树欲静而风不止 ------>
import javax.swing.JLabel;
import javax.swing.ImageIcon;public class Applet1 extends Applet {
public Applet1() {
}public void init() {
JLabel label = new JLabel(new ImageIcon(getImage(getCodeBase(),"icon.gif")));
//getCodeBase()将得到你页面文件所在的绝对路径,这很关键,如果你的图片方在和页面相同的位置,这样就可以了。
this.add(label);
}}<------ 树欲静而风不止 ------>
to mq612(理想) :我照你的方法对程序进行了修改,结果还是如我在这贴所讲的,单单在IE里看不到。
但是我们老师说过了那个CODE里只放一个文件名字就行啦
如果不在同一个文件夹里
就要在那个CODEBASE里打上那个文件的路径就行了
我想你试试看吧现在要是不用那个命令形的
你就去下了个JCREATOR用吧
很好用的
Icon icon=new ImageIcon(getImage(getCodeBase(),"1.gif"));
改为:<applet code="D:\\jdk1.3.0_01\\bin\\Test1.class" width=300 height=200>
再试试
结贴!