?? mymidlet.java
字號:
package game;
import java.io.IOException;
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.Image;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
/**
* @author Administrator
* 主類
* TODO 要更改此生成的類型注釋的模板,請轉至
* 窗口 - 首選項 - Java - 代碼樣式 - 代碼模板
*/
public class MyMIDlet extends MIDlet implements CommandListener {
private static Command exitCmd; //這時也可以對exitCmd進行初始化
private static Command okCmd;
private static Image img = null;
private static Form form1; //當前顯示時要用到
public static MyMIDlet instance;
private MyCanvas mycanvas; //調入下一界面時要用到
private Display dispaly;
public MyMIDlet(){
super();
instance = this;
dispaly = Display.getDisplay(this); //獲取屏幕對象
okCmd = new Command("進入", Command.OK, 1); //聲明一個按紐的對象變量
exitCmd = new Command("離開", Command.EXIT, 1);
form1=new Form(" Royal Studio V1.0");
form1.addCommand(exitCmd); //添加按紐
form1.addCommand(okCmd);
form1.setCommandListener(this); //偵聽
form1.append(" WellCome To Play Game ! ");
try {
img=Image.createImage("/20.png");
}
catch (IOException e) { }
form1.append(img);
form1.append(" Powered By Tenghe.Co");
form1.append(" " + " 版本信息2005.11.06 ");
}
protected void startApp() throws MIDletStateChangeException {
Display.getDisplay(MyMIDlet.instance).setCurrent(form1);
//注意這里不能直接用display.setCurrent(form1);具體待研究
}
protected void pauseApp(){}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
// TODO Auto-generated method stub
}
public void commandAction(Command command, Displayable displayable) {
if (command == okCmd){ //響應按紐,調用別的方法
mycanvas = new MyCanvas();
Display.getDisplay(MyMIDlet.instance).setCurrent(mycanvas); //進入下一界面
//display.setCurrent(new MyCanvas(display));
mycanvas.startup();
}
if (command == exitCmd) {
//MyMIDlet.instance.quitApp();
this.notifyDestroyed();
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -