我用myeclipse运行J2ME程序为什么模拟器一闪而过,为什么,怎么解决?请诸位高手们帮帮忙?
我的程序代码是:importjavax.microedition.lcdui.*;importjavax.microedition.midlet.*;publicclas...
我的程序代码是:
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class HelloWorld extends MIDlet implements CommandListener{
private Command exitCommand;
private TextBox tb;
public HelloWorld(){
exitCommand=new Command("Exit",Command.EXIT,1);
tb=new TextBox("Hello MIDlet","Hello Java World!",12,0);
tb.addCommand(exitCommand);
tb.setCommandListener(this);
}
protected void startApp() throws MIDletStateChangeException{
Display.getDisplay(this).setCurrent(tb);
System.out.println("startApp");
}
protected void pauseApp(){
System.out.println("pauseApp");
}
protected void destroyApp(boolean c) throws MIDletStateChangeException{
System.out.println("destroyApp");
}
public void commandAction(Command c,Displayable d){
if(c==exitCommand){
try{destroyApp(false);
}catch(MIDletStateChangeException exception){
System.out.println("MIDletStateChangeException");
}
notifyDestroyed();
}
}
}
运行以后在console面板中出现:
正在通过存储根 C:\Users\lenovo\j2mewtk\2.5.2\appdb\DefaultColorPhone 来运行
Running with locale: Chinese (Simplified)_People's Republic of China.936
Running in the identified_third_party security domain
java.lang.IllegalArgumentException
at javax.microedition.lcdui.TextField.setChars(+105)
at javax.microedition.lcdui.TextField.setString(+27)
at javax.microedition.lcdui.TextField.<init>(+168)
at javax.microedition.lcdui.TextBox.<init>(+74)
at HelloWorld.<init>(+35)
at java.lang.Class.runCustomCode(+0)
at com.sun.midp.midlet.MIDletState.createMIDlet(+34)
at com.sun.midp.midlet.Scheduler.schedule(+52)
at com.sun.midp.main.Main.runLocalClass(+28)
at com.sun.midp.main.Main.main(+80)
Execution completed.
3387201 bytecodes executed
46 thread switches
1667 classes in the system (including system classes)
17772 dynamic objects allocated (533496 bytes)
2 garbage collections (456816 bytes collected)
谢谢了! 展开
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class HelloWorld extends MIDlet implements CommandListener{
private Command exitCommand;
private TextBox tb;
public HelloWorld(){
exitCommand=new Command("Exit",Command.EXIT,1);
tb=new TextBox("Hello MIDlet","Hello Java World!",12,0);
tb.addCommand(exitCommand);
tb.setCommandListener(this);
}
protected void startApp() throws MIDletStateChangeException{
Display.getDisplay(this).setCurrent(tb);
System.out.println("startApp");
}
protected void pauseApp(){
System.out.println("pauseApp");
}
protected void destroyApp(boolean c) throws MIDletStateChangeException{
System.out.println("destroyApp");
}
public void commandAction(Command c,Displayable d){
if(c==exitCommand){
try{destroyApp(false);
}catch(MIDletStateChangeException exception){
System.out.println("MIDletStateChangeException");
}
notifyDestroyed();
}
}
}
运行以后在console面板中出现:
正在通过存储根 C:\Users\lenovo\j2mewtk\2.5.2\appdb\DefaultColorPhone 来运行
Running with locale: Chinese (Simplified)_People's Republic of China.936
Running in the identified_third_party security domain
java.lang.IllegalArgumentException
at javax.microedition.lcdui.TextField.setChars(+105)
at javax.microedition.lcdui.TextField.setString(+27)
at javax.microedition.lcdui.TextField.<init>(+168)
at javax.microedition.lcdui.TextBox.<init>(+74)
at HelloWorld.<init>(+35)
at java.lang.Class.runCustomCode(+0)
at com.sun.midp.midlet.MIDletState.createMIDlet(+34)
at com.sun.midp.midlet.Scheduler.schedule(+52)
at com.sun.midp.main.Main.runLocalClass(+28)
at com.sun.midp.main.Main.main(+80)
Execution completed.
3387201 bytecodes executed
46 thread switches
1667 classes in the system (including system classes)
17772 dynamic objects allocated (533496 bytes)
2 garbage collections (456816 bytes collected)
谢谢了! 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询