?? mycanvas.java
字號(hào):
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Graphics;
class MyCanvas extends Canvas implements Runnable, CommandListener {
MainLet midplet;
private Command send;
private Command resend;
/**
*
*/
public MyCanvas(MainLet midplet) {
this.midplet=midplet;
new Thread(this).start();
send=new Command("send",Command.SCREEN,1);
resend=new Command("resend",Command.SCREEN,1);
this.addCommand(send);
this.addCommand(resend);
this.setCommandListener(this);
}
protected void paint(Graphics g) {
g.fillRect(0,0,getWidth(),getHeight());
if(midplet.getIsSend()){
g.drawString("send ok",0,0,Graphics.LEFT|Graphics.TOP);
}else if(midplet.getIsSending()){
g.drawString("sending.....",0,0,Graphics.LEFT|Graphics.TOP);
}else{
g.drawImage(midplet.getImage(),0,0,Graphics.LEFT|Graphics.TOP);
}
}
public void run(){
while(true){
repaint();
try{
Thread.sleep(100);
}catch(Exception e){System.out.println("sleep");}
}
}
public void commandAction(Command c, Displayable arg1) {
System.out.println("send");
if(c==send){
try{
if(!midplet.getIsSending()){
doSearch();
}
}catch(Exception e){e.printStackTrace();System.out.println("hahaha");}
}
else{
if(c==resend){
try{
midplet.setIsSend(false);
midplet.setIsSending(true);
this.notifyAll();
}catch(Exception e){System.out.println("en?");}
}
}
}
private synchronized void doSearch(){
midplet.setIsSending(true);
midplet.wakeUpConn();
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -