?? alerttypetest.java
字號:
/*
* AlertTypeTest.java
*
* Copyright 2001 SkyArts. All Rights Reserved.
*/
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.util.Vector;
import javax.microedition.rms.*;
/**
* 播放AlertType聲音的MIDlet
*
* @author Hideki Yonekawa
* @version 1.0
*/
public class AlertTypeTest extends MIDlet implements CommandListener {
/** 顯示AlertType清單用的List變量 */
private List typeList = new List("AlertType", Choice.IMPLICIT);
/** 結束命令 */
private Command quitCmd = new Command("結束", Command.SCREEN, 1);
/** 構建函數 */
public AlertTypeTest() {
// 制作AlertType的List清單
typeList.append("ALARM", null);
typeList.append("CONFIRMATION", null);
typeList.append("ERROR", null);
typeList.append("INFO", null);
typeList.append("WARNING", null);
typeList.addCommand(quitCmd);
typeList.setCommandListener(this);
// 顯示AlertType的List清單
Display.getDisplay(this).setCurrent(typeList);
}
/** MIDlet開始時所調用的方法 */
protected void startApp() throws MIDletStateChangeException {}
/** MIDlet暫停時所調用的方法 */
protected void pauseApp() {}
/** MIDlet結束時所調用的方法 */
protected void destroyApp(boolean unconditional)
throws MIDletStateChangeException {}
/**
* Command事件發生時調用的方法
* 依List選擇來調用
*/
public void commandAction(Command c, Displayable d) {
if(d == typeList) {
//List清單顯示時
if(c == List.SELECT_COMMAND) {
//依List來選擇
//依選擇List當Index來播放AlertType聲音
switch(typeList.getSelectedIndex()) {
case 0:
AlertType.ALARM.playSound(Display.getDisplay(this));
break;
case 1:
AlertType.CONFIRMATION.playSound(Display.getDisplay(this));
break;
case 2:
AlertType.ERROR.playSound(Display.getDisplay(this));
break;
case 3:
AlertType.INFO.playSound(Display.getDisplay(this));
break;
case 4:
AlertType.WARNING.playSound(Display.getDisplay(this));
break;
}
}else {
//List選擇范圍以外時
if(c == quitCmd) {
//選擇了結束命令時
//MIDlet結束
try {
destroyApp(false);
notifyDestroyed();
}catch(Exception e) {}
}
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -