?? confirmationdialog.java
字號:
package com.j2medev.chapter3.dialog;
import javax.microedition.lcdui.*;
//定義兩個常量代表用戶的選擇
public static final int YES = 0;
public static final int NO = 1;
protected Form wait;//用于實現對話框的組件
protected Command noCommand;
protected Command yesCommand;
private String message;
private String yesLabel;
private String noLabel;
public ConfirmationDialog(Display display, String message) {
this(display, message, null, null);
}
public ConfirmationDialog(Display display, String amessage,
String ayesLabel, String anoLabel) {
super(display);
this.message = (amessage == null) ? "繼續操作?" : amessage;
this.yesLabel = (yesLabel == null) ? "確定" : ayesLabel;
this.noLabel = (noLabel == null) ? "返回" : anoLabel;
yesCommand = new Command(yesLabel, Command.OK, 1);
noCommand = new Command(noLabel, Command.CANCEL, 1);
wait = new Form("對話框");
wait.append(message);
wait.addCommand(yesCommand);
wait.addCommand(noCommand);
wait.setCommandListener(this);
}
public void commandAction(Command c, Displayable d) {
if (c == yesCommand) {
dismiss(YES);
} else if (c == noCommand) {
dismiss(NO);
}
}
//實現Dialog的抽象方法,返回wait。
protected Displayable getDisplayable() {
return wait;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -