📄 lighthousemidlet.java
字号:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class LighthouseMIDlet extends MIDlet implements CommandListener {
private Form initForm;
private ChoiceGroup choices;
private LHCanvas gameCanvas;
public void startApp() {
// Create the Init form
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);
}
public void pauseApp() {}
public void destroyApp(boolean unconditional) {
gameCanvas.stop();
}
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 (gameCanvas == null) {
gameCanvas = new LHCanvas(Display.getDisplay(this), name);
Command exitCommand = new Command("Exit", Command.EXIT, 0);
gameCanvas.addCommand(exitCommand);
gameCanvas.setCommandListener(this);
}
// Start up the gameCanvas
gameCanvas.start();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -