代码:
/*
* Created on 2004-6-20
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package cn.edu.xtu.tilepuzzle.ui;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.TextField;
public class HelpUI implements CommandListener{
private Command btnExit;
private Command btnYes;
private Form formMain;
private TextField txtContent;
private String helpContent="";
private Display display;
Displayable displayable;
public HelpUI( Display display,Displayable displayable) {
//super(title);
this.display=display;
this.displayable=displayable;
loadMainForm();
}
/*
* 初始化主界面
*/
void loadMainForm(){
helpContent="新游戏:"+"开始新的游戏。\n"
+"设置图片:"+"设置拼图秘设置的背景图片。\n"
+"最佳成绩:"+ "显示以往玩家保留记录的最佳成绩。\n"
+"选项:"+ "游戏的一些设置:最否显示行列标记,设置游戏的行列数等。\n"
+"帮助:"+ "查看帮助文档。\n"
+"游戏重置:"+ "把游戏设置到刚进入游戏界面时的状态。\n"
+"作弊:"+ "玩家没有玩完游戏立刻进入游戏胜利状态。\n"
+"其它说明:"+ "......";
formMain = new Form("游戏帮助");
txtContent = new TextField("说明:", helpContent, 1000, 0);
btnExit = new Command("返回", Command.EXIT, 1);
btnYes = new Command("确定", Command.EXIT, 0);
formMain.append(txtContent);
/*formMain.append(new TextField("新游戏:", "开始新的游戏。", 120, 0));
formMain.append(new TextField("设置图片:", "设置拼图秘设置的背景图片。", 120, 0));
formMain.append(new TextField("最佳成绩:", "显示以往玩家保留记录的最佳成绩。", 120, 0));
formMain.append(new TextField("选项:", "游戏的一些设置:最否显示行列标记,设置游戏的行列数等。", 120, 0));
formMain.append(new TextField("帮助:", "查看帮助文档。", 120, 0));
formMain.append(new TextField("游戏重置:", "把游戏设置到刚进入游戏界面时的状态。", 120, 0));
formMain.append(new TextField("作弊:", "玩家没有玩完游戏立刻进入游戏胜利状态。", 120, 0));
formMain.append(new TextField("其它说明:", "......", 120, 0));
*/
formMain.addCommand(btnYes);
formMain.addCommand(btnExit);
formMain.setCommandListener(this);
this.display.setCurrent(formMain);
}
/*
* 命令处理
* @see javax.microedition.lcdui.CommandListener#commandAction(javax.microedition.lcdui.Command, javax.microedition.lcdui.Displayable)
*/
public void commandAction(Command command, Displayable display){
if(command == btnExit || command == btnYes ){
this.display.setCurrent(displayable);
}
}
}
运行时显示如图: