📄 alerttypedemo.java
字号:
import javax.microedition.lcdui.*;import javax.microedition.midlet.MIDlet;public class AlertTypeDemo extends MIDlet implements CommandListener{ private Command CMD_EXIT=new Command("Exit",Command.EXIT,1); private Command CMD_INFO=new Command("INFO",Command.SCREEN,2); private Command CMD_WARN=new Command("WARN",Command.SCREEN,3); private Command CMD_ERROR=new Command("ERROR",Command.SCREEN,4); private Command CMD_ALARM=new Command("ALARM",Command.SCREEN,5); private Command CMD_CONF=new Command("CONFIRMATION",Command.SCREEN,6); private Display display; private Form mainForm; private AlertType alertType; public AlertTypeDemo() { display = Display.getDisplay(this); alertType = AlertType.ALARM; mainForm = new Form("AlertType演示播放声音"); mainForm.addCommand(CMD_EXIT); mainForm.addCommand(CMD_INFO); mainForm.addCommand(CMD_WARN); mainForm.addCommand(CMD_ERROR); mainForm.addCommand(CMD_ALARM); mainForm.addCommand(CMD_CONF); mainForm.setCommandListener(this); } protected void startApp() { display.setCurrent(mainForm); } protected void destroyApp(boolean unconditional) { } protected void pauseApp() { } public void commandAction(Command c, Displayable s) { int priority = c.getPriority(); switch(priority){ case 2:alertType = AlertType.INFO;break; case 3:alertType = AlertType.WARNING;break; case 4:alertType = AlertType.ERROR;break; case 5:alertType = AlertType.ALARM;break; case 6: alertType = AlertType.CONFIRMATION;break; } if(alertType.playSound(display)){ mainForm.append("声音已经播放\n"); } if (c == CMD_EXIT){ destroyApp(false); notifyDestroyed(); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -