出现java.lang.IllegalAccessException是什么原因?

frankinlu 2003-06-28 12:22:14
最近写了一个j2me的程序,在sun的wtk中运行,build 时没有任何错误,
但在run时却抛出这个例外,这是为什么?
源代码如下:
package com.mot.j2me.midlets.ocrtest;

import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;

class ocrtest extends MIDlet implements CommandListener
{
Display display = Display.getDisplay(this);

public Command okCommand = new Command("Yes" , Command.OK,0),
exitCommand = new Command("Leave", Command.EXIT,1);

public List optionList ;
public ocrtest()
{
optionList = new List("Begin work ? " , List.IMPLICIT);
optionList.addCommand(okCommand);
optionList.addCommand(exitCommand);
optionList.setCommandListener(this);
}
protected void startApp() throws MIDletStateChangeException
{
display.setCurrent(optionList);
}
protected void pauseApp(){}
protected void destroyApp(boolean unconditional){}

public void commandAction(Command c , Displayable d)
{
if( d == optionList )
{
if ( c == exitCommand )
{
notifyDestroyed();
}else
{
//System.out.println("succeed!!!");
}
}
}
}

谢谢拉
...全文
1211 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
zzutligang 2003-06-28
  • 打赏
  • 举报
回复
来晚了!!
jofield 2003-06-28
  • 打赏
  • 举报
回复
optionList.setCommandListener(this);
把这句放到public void startApp() {}中。

13,100

社区成员

发帖
与我相关
我的任务
社区描述
Java J2ME
社区管理员
  • J2ME社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧