?? gamemidlet.java
字號:
import javax.microedition.midlet.* ;
import javax.microedition.lcdui.* ;
public class GameMIDlet extends MIDlet
implements CommandListener
{
/*定義舞臺*/
Display display ;
private Server server;
private Client client;
private static final String SERVER = "Server";
private static final String CLIENT = "Client";
/*定義選擇畫面*/
private static final String[] names = {SERVER, CLIENT};
private Form f;
private ChoiceGroup cg;
Command c1,exitCommand;
public GameMIDlet()
{ exitCommand = new Command("exit", Command.EXIT,2);
c1=new Command("結(jié)束", Command.EXIT, 1);
display = Display.getDisplay(this) ;
}
/*初始化選擇畫面*/
public void begin()
{ f = new Form("泡泡車");
cg = new ChoiceGroup("請選擇類型",Choice.EXCLUSIVE, names, null);
f.append(cg);
f.addCommand(new Command("開始", Command.OK, 1));
f.addCommand(c1);
f.setCommandListener(this);
display.setCurrent(f);
}
public void startApp()
{
begin();
}
/*按鍵事件監(jiān)聽*/
public void commandAction(Command c,Displayable s)
{
String cmd = c.getLabel() ;
if(cmd.equals("開始"))
{
String name = cg.getString(cg.getSelectedIndex());
if (name.equals(SERVER)) {
server = new Server(this);
server.start();
}
else {
client = new Client(this);
client.start();
}
}else if(cmd.equals("結(jié)束"))
{
notifyDestroyed() ;
}
else if(cmd.equals("Exit"))
{if (server != null) {
server.stop();
}
if (client != null) {
client.stop();
}
begin();
}
}
public void pauseApp()
{
}
public void destroyApp(boolean unconditional)
{
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -