?? btgame.java
字號:
package bluetoochgame;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class BTGame extends MIDlet implements CommandListener{
private static BTGame instance;
private MyCanvas mycanvas ;
private ChoiceGroup choices;
private Form initForm;
/** Constructor */
public BTGame() {
instance = this;
}
/** Main method */
public void startApp() {
initForm = new Form("Connect 4");
// Add the peer choice group
String[] peerNames = { "Server", "Client" };
choices = new ChoiceGroup("Please select peer type:", Choice.EXCLUSIVE, peerNames, null);
initForm.append(choices);
// Add the Exit and Play commands
Command exitCommand = new Command("Exit", Command.EXIT, 0);
initForm.addCommand(exitCommand);
Command playCommand = new Command("Play", Command.OK, 0);
initForm.addCommand(playCommand);
initForm.setCommandListener(this);
// Set the form as the current screen
Display.getDisplay(this).setCurrent(initForm);
// Display.getDisplay(this).setCurrent(displayable);
}
/** Handle pausing the MIDlet */
public void pauseApp() {
}
/** Handle destroying the MIDlet */
public void destroyApp(boolean unconditional) {
}
/** Quit the MIDlet */
public static void quitApp() {
instance.destroyApp(true);
instance.notifyDestroyed();
instance = null;
}
public void commandAction(Command c, Displayable s) {
if (c.getCommandType() == Command.EXIT) {
destroyApp(true);
notifyDestroyed();
}
else if (c.getCommandType() == Command.OK) {
// Find out which type of peer connection is being used
String name = choices.getString(choices.getSelectedIndex());
// Create the game canvas
if (mycanvas == null) {
mycanvas = new MyCanvas(Display.getDisplay(this), name);
Command exitCommand = new Command("Exit", Command.EXIT, 0);
mycanvas.addCommand(exitCommand);
mycanvas.setCommandListener(this);
// Start up the gameCanvas
mycanvas.start();
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -