新人提问,不知道这个异常是怎么回事
一点运行的时候就提示这个异常
【Uncaught exception java/lang/Error: Static initializer: java/lang/IllegalArgumentException.】
不知道是怎么回事,以为是不是模拟器不支持。。
然后放到我的手机上测试,一运行,就提示“无法检测的异常”,然后关闭程序了。
下面是代码。。帮忙看看吧。我是看不到。。
package MIDlet;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
/**
* @author Administrator
*/
public class StackMIDlet extends MIDlet implements CommandListener{
private static final int msgSave = 20;
private static final int max_size = 256;//URL长度
public static final String strExit = "Exit";
public static final String strPost = "Post";
public static final String strSettingTitle = "Settings";//“设置”窗口的标题
public static final String strBack = "Back";
public static final String strSave = "Save";
private TextField urlText = null;//设置
private static Display display = null;
public static final Command exit = new Command(strExit,Command.EXIT, 1);
public static final Command setting = new Command(strSettingTitle, Command.ITEM, 2);
public static final Command cmdPost = new Command(strPost, Command.OK, 3);
public static final Command cmdBack = new Command(strBack, Command.BACK, 4);
public static final Command cmdSave = new Command(strSave, msgSave, 5);
private Form SettingForm = null;//用于设置信息的窗口
private Form mainForm = null;
public StackMIDlet() {
}
public void startApp() {
if(display == null) {
display = Display.getDisplay(this);
mainForm = new Form("第一个窗口");
mainForm.addCommand(exit);
mainForm.addCommand(setting);
mainForm.setCommandListener(this);
display.setCurrent(mainForm);
}
}
//初始化“设置窗口”
private void ShowSettingForm(){
if(SettingForm != null)
return;
urlText = new TextField("服务器PHP地址:", "", max_size, TextField.URL);
SettingForm = new Form(strSettingTitle);//实例化Form窗口
SettingForm.append(urlText);
SettingForm.addCommand(cmdBack);
SettingForm.addCommand(cmdSave);
SettingForm.setCommandListener(this);
display.setCurrent(SettingForm);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c, Displayable d) {
if (c == exit) {
destroyApp(false);
notifyDestroyed();
}else if (c == setting) {
ShowSettingForm();
}else if (c == cmdBack) {
//display.setCurrent(mainForm);
ShowMsg("123");
}else if (c == cmdSave) {//保存数据
char[] data = new char[max_size + 1];
urlText.getChars(data);
ReadLog log = new ReadLog();
log.AddLog(new String(data));
ShowMsg("保存成功");
}
}
private void ShowMsg(String msg){
Alert show = new Alert("提示", msg, null, AlertType.INFO);
show.setTimeout(2000);
display.setCurrent(show, mainForm);
}
}