?? dialog.java
字號:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
class DialogListener {
public void onOK() { };
public void onYES() { };
public void onNO() { };
public void onCANCELK() { };
public void onCONFOIRM() { };
}
public class Dialog extends Form implements CommandListener {
Display display;
DialogListener dll;
Displayable parent;
public static final int OK = 1;
public static final int YES = 2;
public static final int NO = 4;
public static final int CANCEL = 8;
public static final int CONFIRM = 16;
Command cmOK;
Command cmYES;
Command cmNO;
Command cmCANCEL;
Command cmCONFIRM;
StringItem text;
public Dialog(String title, String text, int mode, MIDlet midlet,
DialogListener dll, Displayable dis) {
super(title);
this.dll = dll;
this.text = new StringItem(null, text);
this.display = Display.getDisplay(midlet);
this.parent = dis;
if ((mode & OK) != 0) {
cmOK = new Command("確定", Command.OK, 1);
addCommand(cmOK);
}
if ((mode & YES) != 0) {
cmYES = new Command("是", Command.OK, 1);
addCommand(cmYES);
}
if ((mode & CANCEL) != 0) {
cmCANCEL = new Command("取消", Command.CANCEL, 1);
addCommand(cmCANCEL);
}
if ((mode & CONFIRM) != 0) {
cmCONFIRM = new Command("應用", Command.SCREEN, 1);
addCommand(cmCONFIRM);
}
if ((mode & NO) != 0) {
cmNO = new Command("否", Command.EXIT, 1);
addCommand(cmNO);
}
append(text);
setCommandListener(this);
}
public void commandAction(Command c, Displayable s) {
if (dll != null) {
if (c == cmOK)
dll.onOK();
else if (c == cmYES)
dll.onYES();
else if (c == cmNO)
dll.onNO();
else if (c == cmCANCEL)
dll.onCANCELK();
else if (c == cmCONFIRM)
dll.onCONFOIRM();
}
display.setCurrent(parent);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -