?? commandlistenerdemo.java
字號:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class CommandListenerDemo extends MIDlet implements CommandListener
{
private Display display;
private Alert alert;
private Form form;
private Command exit;
private Command submit;
public CommandListenerDemo()
{
display = Display.getDisplay(this);
exit = new Command("退出", Command.EXIT, 1);
submit=new Command("提交", Command.SCREEN, 2);
form = new Form("CommandListener監聽器");
form.addCommand(exit);
form.addCommand(submit);
form.setCommandListener(this);
}
public void startApp()
{
display.setCurrent(form);
}
public void pauseApp()
{
}
public void destroyApp(boolean unconditional)
throws MIDletStateChangeException
{
if (unconditional == false)
{
throw new MIDletStateChangeException();
}
}
public void commandAction(Command command, Displayable displayable)
{
if (command == submit)
{
alert = new Alert("監聽器", "響應Command觸發的事件",
null, AlertType.WARNING);
alert.setTimeout(Alert.FOREVER);
display.setCurrent(alert, form);
}
else if(command==exit)
{
try
{
destroyApp(false);
notifyDestroyed();
}
catch (MIDletStateChangeException exception)
{
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -