?? menulist.java
字號:
import javax.microedition.lcdui.*;
class MenuList extends List implements CommandListener
{
private escapeeMIDlet midlet;
private Command exitCommand;
private boolean gameActive = false;
MenuList(escapeeMIDlet midlet)
{
super("逃亡者", List.IMPLICIT);
this.midlet = midlet;
append("開始新游戲", null);
append("高分記錄", null);
append("游戲說明", null);
exitCommand = new Command("退出", Command.EXIT, 1);
addCommand(exitCommand);
setCommandListener(this);
}
void setGameActive(boolean active)
{
if (active && !gameActive)
{
gameActive = true;
insert(0, "繼續游戲", null);
}
else if (!active && gameActive)
{
gameActive = false;
delete(0);
}
}
public void commandAction(Command c, Displayable d)
{
if (c == List.SELECT_COMMAND)
{
int index = getSelectedIndex();
if (index != -1) // should never be -1
{
if (!gameActive)
{
index++;
}
switch (index)
{
case 0: // Continue
midlet.menuListContinue();
break;
case 1: // New game
midlet.menuListNewGame();
break;
case 2: // High score
midlet.menuListHighScore();
break;
case 3:
midlet.menuListInstructions();
break;
default:
// can't happen
break;
}
}
}
else if (c == exitCommand)
{
midlet.menuListQuit();
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -