ImageCanvas.java
上传用户:gyyuli
上传日期:2013-07-09
资源大小:3050k
文件大小:1k
源码类别:

J2ME

开发平台:

Java

  1. package transimagedemo;
  2. import javax.microedition.lcdui.*;
  3. import javax.microedition.midlet.*;
  4. import javax.microedition.lcdui.game.*;
  5. import java.io.*;
  6. import java.lang.*;
  7. public class ImageCanvas extends Canvas
  8. {
  9.         private Image image;
  10.         private Image transimage;
  11. public ImageCanvas()
  12.         {
  13.         }
  14.         public void paint(Graphics g)
  15.         {
  16.         
  17.         g.setColor(0x00000000);
  18. g.fillRect(0, 0, this.getWidth(), this.getHeight());
  19.         try{
  20.         image = Image.createImage("/girl.png"); 
  21.         transimage = Image.createImage("/trans_girl.png"); 
  22.         }catch(java.io.IOException e){
  23.         System.out.println(e.getMessage());
  24.         }
  25.         g.drawImage(image,getWidth()/2,10,g.TOP|g.HCENTER);
  26.         g.drawImage(transimage,getWidth()/2,50+image.getHeight(),g.VCENTER|g.HCENTER);
  27.         }
  28.        
  29.         
  30.         
  31.         
  32. }