日期:2014-05-20 浏览次数:20802 次
import java.awt.*; import java.applet.*; import java.awt.geom.*; import java.awt.font.*; import java.awt.font.*; import java.awt.image.*; import java.net.*; import java.net.URL; public class GUIImage extends Applet{ public void paint(Graphics oldg) { Graphics2D g=(Graphics2D)oldg; try { URL imgURL=new URL(getDocumentBase(),"Test.gif"); Image img=getImage(imgURL); int h=img.getHeight(this); int w=img.getWidth(this); BufferedImage buf=new BufferedImage(w,h,BufferedImage.TYPE_INT_ARGB); Graphics tmpG=buf.createGraphics(); tmpG.drawImage(img,10,10,this); g.drawImage(buf,10,20,this); } catch(Exception e) { System.out.println("Error:"+e.getMessage()); } } }