?? gobang.java
字號:
package com.j2medev.chapter5;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
public class GoBang extends MIDlet implements CommandListener{
private static GoBang instance = null;
private Display display = null;
private List menu = null;
public static final String[] titles = {"Connect to network","Play with Computer","settings"};
public void startApp() {
if(display == null){
display = Display.getDisplay(this);
instance = this;
//初始化游戲主菜單
menu = new List("GoBang",List.IMPLICIT,titles,null);
menu.setCommandListener(this);
menu.addCommand(new Command("Exit",Command.EXIT,1));
}
display.setCurrent(menu);
}
public Displayable getMenu(){
return menu;
}
public static void setCurrent(Displayable displayable){
instance.display.setCurrent(displayable);
}
public static void setCurrent(Alert alert,Displayable displayable){
instance.display.setCurrent(alert,displayable);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command command, Displayable displayable) {
if(command.getCommandType() == Command.EXIT){
destroyApp(false);
notifyDestroyed();
}else if(command == List.SELECT_COMMAND){
int index = menu.getSelectedIndex();
if(index == 0){
//聯網對站,連接服務器
Form form = new Form("Connect to server");
form.append("please wait... application is connecting to game server");
display.setCurrent(form);
new Thread(new GameEngine(this)).start();
}else if(index == 1){
//與電腦對站,讀者自行實現
}else{
//關于
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -