ImageCanvas.java
资源名称:J2ME&Game.rar [点击查看]
上传用户:gyyuli
上传日期:2013-07-09
资源大小:3050k
文件大小:1k
源码类别:
J2ME
开发平台:
Java
- package transimagedemo;
- import javax.microedition.lcdui.*;
- import javax.microedition.midlet.*;
- import javax.microedition.lcdui.game.*;
- import java.io.*;
- import java.lang.*;
- public class ImageCanvas extends Canvas
- {
- private Image image;
- private Image transimage;
- public ImageCanvas()
- {
- }
- public void paint(Graphics g)
- {
- g.setColor(0x00000000);
- g.fillRect(0, 0, this.getWidth(), this.getHeight());
- try{
- image = Image.createImage("/girl.png");
- transimage = Image.createImage("/trans_girl.png");
- }catch(java.io.IOException e){
- System.out.println(e.getMessage());
- }
- g.drawImage(image,getWidth()/2,10,g.TOP|g.HCENTER);
- g.drawImage(transimage,getWidth()/2,50+image.getHeight(),g.VCENTER|g.HCENTER);
- }
- }