温习了下applet...
ImageScrap.java
import java.applet.*;
import java.awt.Graphics;
import java.awt.Image;
import java.net.URL;
public class ImageScrap extends Applet{
/**
*
*/
private static final long serialVersionUID = -547062993784720870L;
Image p_w_picpath;
Image p_w_picpath2;
public void init(){
String url= "http://www.showsee.cn/img/阿朵.jpg";
try{
p_w_picpath=getImage(new URL(url));
//p_w_picpath=getImage(getCodeBase(),"Image.gif");
p_w_picpath2=getImage(getCodeBase(),"Image.jpg");
}catch(Exception e){
}
}
public void paint(Graphics g){
g.drawImage(p_w_picpath, 0,0,this);
g.drawImage(p_w_picpath2, 0, 240, this);
}
}
import java.awt.Graphics;
import java.awt.Image;
import java.net.URL;
public class ImageScrap extends Applet{
/**
*
*/
private static final long serialVersionUID = -547062993784720870L;
Image p_w_picpath;
Image p_w_picpath2;
public void init(){
String url= "http://www.showsee.cn/img/阿朵.jpg";
try{
p_w_picpath=getImage(new URL(url));
//p_w_picpath=getImage(getCodeBase(),"Image.gif");
p_w_picpath2=getImage(getCodeBase(),"Image.jpg");
}catch(Exception e){
}
}
public void paint(Graphics g){
g.drawImage(p_w_picpath, 0,0,this);
g.drawImage(p_w_picpath2, 0, 240, this);
}
}
ShowImage.html
<
html
>
< head >
< title >imag </title>
</head>
< center >
< applet code ="ImageScrap.class" width=240 height=400 >
</applet>
</html>
< head >
< title >imag </title>
</head>
< center >
< applet code ="ImageScrap.class" width=240 height=400 >
</applet>
</html>
ie7.0 不能显示applet,但用appletviewer ShowImage.html可以。应该是ie没有java sun控制台的原因。工具-管理加载项中也没有。不过实验室的ie6.0却有,奇怪了,jdk我都装的好好的。
转载于:https://blog.51cto.com/dongdong1314/135051