?? graycanvas.java.svn-base
字號:
package opusmicro.demos.gray;
import java.io.IOException;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
public class GrayCanvas extends Canvas implements CommandListener{
SoftButton softButton;
Font font = Font.getDefaultFont();
Command leftCommand = new Command("Click",Command.OK,1);
int w ,h;
Image img;
int index;
public GrayCanvas() {
softButton = new SoftButton();
setFullScreenMode(true);
w = getWidth();
h = getHeight();
initImage();
softButton.init(this, font, leftCommand, null);
softButton.setCommandListener(this);
}
Image initImage(){
try {
img = Image.createImage("/welcome.png");
}
catch (IOException e) {
e.printStackTrace();
}
return img;
}
public void keyPressed(int keyCode){
softButton.keyPressed(keyCode);
}
protected void paint(Graphics g) {
g.setColor(-1);
g.fillRect(0, 0, w, h);
paintObject(g);
softButton.paint(g);
if(index==1){
g.setColor(0xABABAB);
fillRect(g, 0, 0, w, h, 0xABABAB);
}
}
private void paintObject(Graphics g){
g.setColor(0xFF4500);
g.fillRect(w/3, h/5, 80, 80);
g.drawImage(img, w/4, h/2, 0);
}
public void fillRect(Graphics g, int x, int y,int w, int h,int ARGBColor) {
int argb[] = new int[w * h];
int a = 100;
for(int i=0;i<argb.length;i++){
argb[i] = (a<<24) | (argb[i]&0x00FFFFFF);
}
g.drawRGB(argb, 0, w, x, y,w, h, true);
}
public void commandAction(Command c, Displayable d) {
if(c == leftCommand){
index = (index+1)%2;
System.out.println("click left command"+ index);
repaint();
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -