ClipCanvas.java
资源名称:J2ME&Game.rar [点击查看]
上传用户:gyyuli
上传日期:2013-07-09
资源大小:3050k
文件大小:1k
源码类别:
J2ME
开发平台:
Java
- package Clip;
- import javax.microedition.lcdui.*;
- import javax.microedition.midlet.*;
- import java.io.*;
- public class ClipCanvas extends Canvas
- {
- public ClipCanvas()
- {
- }
- public void paint(Graphics g)
- {
- System.out.println("区域原点"+g.getClipX());
- System.out.println("区域原点"+g.getClipY());
- System.out.println("区域宽度:"+g.getClipWidth());
- System.out.println("区域高度:"+g.getClipHeight());
- System.out.println("画布宽度:"+getWidth());
- System.out.println("画布高度:"+getHeight());
- /*g.setColor(0x000000);
- int canvasWidth = getWidth();
- int canvasHeight = getHeight();
- g.fillRect(0,0,canvasWidth,canvasHeight);
- g.setClip(canvasWidth/4,canvasHeight/4,canvasWidth/2,canvasHeight/2);
- g.setColor(0xFFFFFF);
- g.fillRect(0,0,canvasWidth,canvasHeight);*/
- g.setColor(0x000000);
- int canvasWidth = getWidth();
- int canvasHeight = getHeight();
- g.fillRect(0,0,canvasWidth,canvasHeight);
- g.setClip(canvasWidth/4,canvasHeight/4,canvasWidth/2,canvasHeight/2);
- // g.setClip(0,0,0,0);
- g.setColor(0xFFFFFF);
- g.fillRect(0,0,canvasWidth,canvasHeight);
- g.clipRect(0,0,canvasWidth/2,canvasHeight/2);
- g.setColor(0xFF0000);
- g.fillRect(0,0,canvasWidth,canvasHeight);
- }
- }