初学J2ME,装了 JB9+WTK2.0....运行书中一代码出现异常..帮忙....

MPU 中金在线 CTO/CIO/技术副总裁/总工程师  2004-09-08 02:58:04
JB 9 + WTK2.0
最基本的程序可以运行...

出现异常代码如下:
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class GraphicsTestCanvas1 extends Canvas
{
public void paint(Graphics g)
{
g.setColor(255,250,0);
//g.setGrayScale(4);
g.fillRect(0,0,getWidth(),getHeight());
int color = g.getColor() ;
int displaycolor = g.getDisplayColor(g.getColor()) ;
System.out.println("目前画面的颜色为:"+Integer.toHexString(color));
System.out.println("目前画面的红色为:"+g.getRedComponent());
System.out.println("目前画面的绿色为:"+g.getGreenComponent());
System.out.println("目前画面的蓝色为:"+g.getBlueComponent());
System.out.println("目前画面的显示颜色为:"+Integer.toHexString(displaycolor));
System.out.println("画面为:"+g.getGrayScale()+"灰度");
}
}
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\Exception\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
C:\WTK20\bin\emulator.exe -classpath "D:\Save\JAVA\wtk_006\classes;" -Xdevice:DefaultColorPhone -Xdescriptor:"D:\Save\JAVA\wtk_006\jad-temp\GraphicsTestCanvas1.jad"
Running with storage root DefaultColorPhone
Unable to create MIDlet GraphicsTestCanvas1
java.lang.InstantiationException: Class not a MIDlet
at com.sun.midp.midlet.MIDletState.createMIDlet(+51)
at com.sun.midp.midlet.Selector.run(+22)
...全文
55 点赞 收藏 6
写回复
6 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
MPU 2004-09-08
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class MyMIDlet extends MIDlet
{
private Display display;
public MyMIDlet()
{
display = Display.getDisplay(this);
}
protected void startApp()
{
GraphicsTestCanvas c = new GraphicsTestCanvas();
display.setCurrent(c);
}
protected void pauseApp()
{
}
protected void destroyApp(boolean unconditional)
{
}
}
/////搞定
回复
王旺旺旺 2004-09-08
另外再建立一个class,应该是如下格式的:

public class MyMIDlet extends MIDlet
{
protected void startApp()
{
}
protected void pauseApp()
{
}
protected void destroyApp(boolean unconditional)
{
}
}
回复
chengfeng 2004-09-08
需要一个作为main class的midlet
回复
chengfeng 2004-09-08
o, midlet
回复
feiyunjian 2004-09-08
没有创建MIDlet类,而且我看起来连线程都没有。。。。。。。。
回复
zealVampire 2004-09-08
Class not a MIDlet
你首先要是个MIDlet啊
回复
相关推荐
发帖
J2ME
创建于2007-09-28

1.3w+

社区成员

Java J2ME
申请成为版主
帖子事件
创建了帖子
2004-09-08 02:58
社区公告
暂无公告