Applet中访问服务器端的图片

-------------------------------------------------------
import java.applet.*;
import java.awt.*;
 
public class DisplayImage extends Applet
 {private Image picture;
 
  public void init()
   {
    setBackground(Color.white);
  picture = getImage(getCodeBase(),"clayon.jpg");
   }
 
  public void paint(Graphics g)
   {   
  g.drawImage(picture, 10, 10, this);
  g.drawImage(picture, 85, 10, 55, 55, this);
  g.drawImage(picture, 150, 10, 40, 40, this);
 
   }
 }
------------------------------------------------------
import java.applet.Applet;
import java.awt.*;
import java.net.*;
 
public class MouseTracker extends Applet{
 
  Image theImage;
 
  public void init(){
    try{
      Toolkit t=java.awt.Toolkit.getDefaultToolkit();
      URL u =new URL ("http://www.google.com.tw/images/hp0.gif");
      theImage = t.getImage(u);
    }
    catch (MalformedURLException e){
      System.err.println(e);
    }
  }
 
  public void paint (Graphics g){
    g.drawImage(theImage,0,0,this);
  }
}
阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页