📄 errorhandling.java
字号:
/*
*
* 错误处理类
*
*/
package card;
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import card.stringtable.ErrorMessageStringTable;
import card.stringtable.TextString;
/**
* @author Georgezc
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class ErrorHandling extends Form implements CommandListener{
public static int IMGNOTFOUND = 1; //图像资源出错类型
public static int RECORDSETERROR = 2; //记录集出错类型
public static int MEDIAERROR = 3; //媒体播放出错类型
public static int INTERRUPTEDERROR = 4; //线程暂停出错类型
String msg;
Display display = null;
Command cmdExit = null;
public ErrorHandling(Display display, int iType) {
super("");
this.display = display;
cmdExit = new Command(TextString.getTxtCmdExitString(), Command.EXIT, 0);
if (iType == IMGNOTFOUND) { //图像资源出错
IOExceptionHandling();
}else if (iType == RECORDSETERROR) { //记录集出错
RecodSetExceptionHandling();
}else if (iType == MEDIAERROR) { //媒体播放出错
MediaExceptionHandling();
}else if (iType == INTERRUPTEDERROR) { //线程暂停出错
InterruptedExceptionHandling();
}
}
public void commandAction(Command c, Displayable d) {
if (c == cmdExit) { //退出按键响应
CardMainMIDlet.quitApp();
}
}
private void IOExceptionHandling() { //图像资源出错处理
Alert altError = new Alert(TextString.getTxtErrorLabelString(), ErrorMessageStringTable.getErrImageString(), null, AlertType.ERROR);
altError.setTimeout(Alert.FOREVER);
altError.addCommand(cmdExit);
altError.setCommandListener(this);
display.setCurrent(altError);
}
private void RecodSetExceptionHandling() { //记录集出错处理
Alert altError = new Alert(TextString.getTxtErrorLabelString(), ErrorMessageStringTable.getErrRecordSetString(), null, AlertType.ERROR);
altError.setTimeout(Alert.FOREVER);
altError.addCommand(cmdExit);
altError.setCommandListener(this);
display.setCurrent(altError);
}
private void MediaExceptionHandling() { //媒体播放出错处理
Alert altError = new Alert(TextString.getTxtErrorLabelString(), ErrorMessageStringTable.getErrMediaString(), null, AlertType.ERROR);
altError.setTimeout(Alert.FOREVER);
altError.addCommand(cmdExit);
altError.setCommandListener(this);
display.setCurrent(altError);
}
private void InterruptedExceptionHandling() { //线程暂停出错处理
Alert altError = new Alert(TextString.getTxtErrorLabelString(), ErrorMessageStringTable.getErrInterruptedString(), null, AlertType.ERROR);
altError.setTimeout(Alert.FOREVER);
altError.addCommand(cmdExit);
altError.setCommandListener(this);
display.setCurrent(altError);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -