📄 serverform.java
字号:
import javax.microedition.lcdui.*;
public class ServerForm extends Form implements CommandListener
{
private Command exit=null,start,get ,config;
private MainSelect mainSelect=null;
private ChoiceGroup saveChoice ,getChoice, musicChoice, soundChoice;
private String choiceString[]={"公开战况","秘密决斗"},saveChoiceString[]={"不保存","保存"} ,getChoiceString[] = {"对战记录","残局记录"} ,musicChoiceString[] = {"打开","关闭"} ,soundChoiceString[] = {"打开","关闭"};
//**************调用记录部分变量
private Form getForm;
private int[][] chess;
public ServerForm(MainSelect ms)
{
super("开始摆擂");
mainSelect=ms;
//*********界面初始化
saveChoice=new ChoiceGroup("是否保存记录",Choice.EXCLUSIVE,saveChoiceString,null);
musicChoice=new ChoiceGroup("背景音乐",Choice.EXCLUSIVE,musicChoiceString,null);
soundChoice=new ChoiceGroup("走步提示",Choice.EXCLUSIVE,soundChoiceString,null);
append(saveChoice);
append(musicChoice);
append(soundChoice);
//*********命令初始化
exit=new Command("Exit",Command.EXIT,1);
start=new Command("Start",Command.OK,1);
get=new Command("Get",Command.OK,1);
addCommand(exit);
addCommand(start);
addCommand(get);
setCommandListener(this);
//通过数组的长度标记是否已经选择了来源
chess = new int[2][2];
}
public void setChess(int[][] chess)
{
this.chess = chess;
}
public void commandAction(Command com,Displayable dis)
{
if(com == exit)
{
if(dis == this)
{
Chess.dis.setCurrent(mainSelect);
}
else
{
Chess.dis.setCurrent(this);
}
}
else if(com==start)
{
int saveIndex=saveChoice.getSelectedIndex();
int musicIndex=musicChoice.getSelectedIndex();
int soundIndex=soundChoice.getSelectedIndex();
//System.out.println("是否公开战况的选项是"+index);
//用chess的长度标记是否已经选择了来源
//System.out.println("chess.length的长度:"+chess.length);
if(chess.length == 2)
{//没有选择来源
new ServerChess(mainSelect,saveIndex,false,chess, musicIndex, soundIndex);
}
else
{//已经选择来源
new ServerChess(mainSelect,saveIndex,true,chess, musicIndex, soundIndex);
}
}
else if(com == get)
{
getForm = new Form("调用记录");
config = new Command("Config",Command.OK,1);
getChoice = new ChoiceGroup("选择来源",Choice.EXCLUSIVE,getChoiceString,null);
getForm.addCommand(exit);
getForm.addCommand(config);
getForm.append(getChoice);
getForm.setCommandListener(this);
Chess.dis.setCurrent(getForm);
}
else if(com == config)
{
int index = getChoice.getSelectedIndex();
//System.out.println("选择的序列号是"+index);
if(index == 1)
{
PhaseListForm phaseListForm = new PhaseListForm(this ,chess);
Chess.dis.setCurrent(phaseListForm);
}
else
{
RecordManage recordManage = new RecordManage(this ,chess);
Chess.dis.setCurrent(recordManage);
}
}
}
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -