?? snakemidlet.java
字號(hào):
import java.io.IOException;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class SnakeMIDlet extends MIDlet implements CommandListener{
private Command exitCommand;
private Command startCommand;
private SnakeCanvas snake;
private Display d;
// private ImageItem imageitem;
// private Image aimage;
TextBox tb;
// Displayable nd;
public SnakeMIDlet() throws IOException {
d=Display.getDisplay(this);
exitCommand=new Command("退出",Command.EXIT,1);
startCommand=new Command("開始",Command.SCREEN,1);
// aimage=Image.createImage("/100_0091.png");
// imageitem=new ImageItem("貪吃蛇",aimage,ImageItem.LAYOUT_CENTER,"和麗新");
tb=new TextBox("貪吃蛇游戲","",256,0);
snake=new SnakeCanvas();
// d.setCurrent(nd);
}
public void startApp() {
tb.addCommand(startCommand);
// Form aform=new Form("貪吃蛇");
// aform.append(imageitem);
// aform.addCommand(startCommand);
// aform.addCommand(exitCommand);
tb.addCommand(exitCommand);
tb.setCommandListener(this);
// d.setCurrent(aform);
d.setCurrent(tb);
// nd.addCommand(exitCommand);
// nd.addCommand(startCommand);
}
public void pauseApp() {}
public void destroyApp(boolean unconditional) {}
public void commandAction(Command c, Displayable arg1) {
// TODO Auto-generated method stub
if(c==exitCommand)
{
destroyApp(true);
notifyDestroyed();
}
else if(c==startCommand)
{
d.setCurrent(snake);
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -