?? mainmenu.java
字號:
package shipwar;
import javax.microedition.lcdui.*;
import javax.microedition.rms.*;
public class MainMenu extends List implements CommandListener{
public static int level=3;
private Play play;
private SetLevel setlevel;
private ViewRecord viewrecord;
private Help help;
private Command Exit=new Command("退出",Command.EXIT,5);
private String[] listname={"3級","4級","5級"};
private Displayable instance;
private Image[] iconArray;
private Image icon;
public static RecordStore rs;
public MainMenu(String[] stringArray,Image[] imageArray,Image icon){
super("深海大戰",List.IMPLICIT,stringArray,imageArray);
this.addCommand(Exit);
this.icon=icon;
try{
rs=RecordStore.openRecordStore("gamerecord",true);
}catch(Exception e){
System.out.println("打開記錄文件失敗");
}
iconArray=new Image[]{icon,icon,icon};
this.instance=this;
this.setCommandListener(this);
}
public void commandAction(Command c,Displayable d){
if(c==Exit)
shipwarMIDlet.quitApp();
else{
switch(this.getSelectedIndex()){
case 0:
play=null;
play=new Play(instance);
Display.getDisplay(shipwarMIDlet.shipwarmidlet).setCurrent(play);
break;
case 1:
setlevel=null;
setlevel=new SetLevel(listname,iconArray,instance);
Display.getDisplay(shipwarMIDlet.shipwarmidlet).setCurrent(setlevel);
break;
case 2:
viewrecord=null;
viewrecord=new ViewRecord(icon,instance);
Display.getDisplay(shipwarMIDlet.shipwarmidlet).setCurrent(viewrecord);
break;
case 3:
help=null;
help=new Help(instance);
Display.getDisplay(shipwarMIDlet.shipwarmidlet).setCurrent(help);
break;
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -