ΪʲôͼƬÎÞ·¨ÏÔʾ°¡
package fish; import javax.swing.*; import java.awt.*; import java.awt.event.*; public class internetfish extends JFrame{ public static void main(String []args){ internetfish fish=new internetfish(); fish.setVisible(true); fish.getContentPane().add(new image2cvs()); } } class image2cvs extends Canvas{ //»²¼ Image img,fish; Image cacheimage; Graphics gs; image2cvs(){ setSize(800,478); Toolkit tl=getToolkit(); img=tl.getImage("images/sea.jpg");//ÔØÈë±³¾°Í¼ } public void paint(Graphics g){ int wt=getWidth(); int ht=getHeight(); cacheimage=createImage(wt,ht); gs=cacheimage.getGraphics(); gs.drawImage(img,0,0,this); } } |