?? simplemidlet.java
字號(hào):
package com.j2medev.chapter2;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
import java.io.*;
public class SimpleMIDlet extends MIDlet implements CommandListener {
private Display display = null;
private Command exitCommand = new Command("Exit", Command.EXIT, 0);
public void startApp() {
//獲得Display實(shí)例
display = Display.getDisplay(this);
Form mainForm = new Form("simple");
Image img = null;
//創(chuàng)建Image對(duì)象
try{
img = Image.createImage("/JavaPowered.png");
}catch(IOException ex){
ex.printStackTrace();
}
if(img != null)
mainForm.append(img);
//添加Command并注冊(cè)監(jiān)聽(tīng)器
mainForm.addCommand(exitCommand);
mainForm.setCommandListener(this);
display.setCurrent(mainForm);
}
public void pauseApp () {}
public void destroyApp(boolean unconditional) {}
//Command事件處理,響應(yīng)用戶按鍵
public void commandAction(Command cmd, Displayable s) {
if (cmd==exitCommand) {
destroyApp(false);
notifyDestroyed();
}
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -