📄 dialogdemo.java
字号:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class DialogDemo extends MIDlet implements CommandListener {
private Command exitCommand;
private TextBox tb;
public DialogDemo() {
exitCommand = new Command("退出程序", Command.EXIT, 1);
tb = new TextBox("对话框演示程序", "显示退出程序提醒对话框", 15, 0);
tb.addCommand(exitCommand);
tb.setCommandListener(this);
}
protected void startApp(){
Display.getDisplay(this).setCurrent(tb);
}
protected void pauseApp() {
}
protected void destroyApp(boolean arg0){
}
public void commandAction(Command c, Displayable d) {
if (c == exitCommand) {
DialogListener dllistener =new DialogListener(){
//实现具体的操作
public void onCONFOIRM(){
//退出程序
System.out.println("exit");
destroyApp(false);
notifyDestroyed();
}
public void onCANCELK(){
System.out.println("cancel");
}
};
Dialog dl = new Dialog("提示","确定需要关闭程序吗?",
Dialog.CANCEL|Dialog.CONFIRM,this,dllistener,tb);
Display.getDisplay(this).setCurrent(dl);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -