📄 snakemidlet.java
字号:
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);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -