?? samplecanvas.java
字號:
package com.j2medev.chapter5;
import javax.microedition.lcdui.*;
import java.io.*;
public class SampleCanvas extends Canvas implements Runnable {
Display m_Display = null;
SampleMIDlet m_MIDlet = null;
Image srcImage = null;
PieceSprite sample = null;
public SampleCanvas(Display display) {
this.m_Display = display;
try {
this.srcImage = Image.createImage("/sample.png");
} catch(IOException ioe) {
ioe.printStackTrace();
}
this.sample = new PieceSprite(this.srcImage, "/sample.bin",(short)100, true);
this.sample.setAnimation(0, true);
this.sample.setFrame((short)0);
new Thread(this).start();
}
/**
* paint
*
* @param graphics Graphics
* @todo Implement this javax.microedition.lcdui.Canvas method
*/
protected void paint(Graphics graphics) {
graphics.setColor(0xFFFFFF);
graphics.fillRect(0, 0, this.getWidth(), this.getHeight());
this.sample.setNextFrame();
this.sample.paint(graphics, this.getWidth()/2, this.getHeight()/2, 0);
}
/**
* run
*/
public void run() {
while(true) {
try {
Thread.sleep(100);
this.repaint();
} catch(Exception e) {
e.printStackTrace();
}
}
}
/**
* start
*/
public void start() {
this.m_Display.setCurrent(this);
}
/**
* keyPressed
* @param keyCode int
*/
public void keyPressed(int keyCode) {
switch(keyCode) {
case Canvas.KEY_NUM5 :
break;
default :
break;
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -