以下这段程序单独编译运行通过,但放在一个Suite中运行时报告"Uncaught exception java/lang/NoClassDefFoundError: Wireless/test/MyCan

LCLLL 2004-09-03 11:41:24
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class FontTest extends MIDlet implements CommandListener{

Display display;
MyCanvas myCanvas;
Command exitCmd;
Command okCmd;
Form form;
ChoiceGroup face, size, style;

public FontTest(){
display = Display.getDisplay(this);
myCanvas = new MyCanvas(this);
form = new Form("选择字型");
face = new ChoiceGroup("Face", List.EXCLUSIVE);
size = new ChoiceGroup("Size", List.EXCLUSIVE);
style = new ChoiceGroup("Style", List.MULTIPLE);
exitCmd = new Command("退出", Command.EXIT, 1);
okCmd = new Command("确定", Command.OK, 1);

face.append("SYSTEM",null);
face.append("PROPORTIONAL",null);
face.append("MONOSPACE",null);
size.append("LARGE",null);
size.append("MEDIUM ",null);
size.append("SMALL ",null);
style.append("BOLD",null);
style.append("ITALIC",null);
style.append("UNDERLINED",null);
form.append(face);
form.append(size);
form.append(style);
form.addCommand(exitCmd);
form.addCommand(okCmd);
form.setCommandListener(this);
}


public void startApp(){
display.setCurrent(form);
}

public void pauseApp(){

}

public void destroyApp(boolean unconditional){

}

public void commandAction(Command c, Displayable d){
if(c == exitCmd){
destroyApp(true);
notifyDestroyed();
}
else if(c == okCmd){
int setFace = face.getSelectedIndex();
int setSize = size.getSelectedIndex();
boolean[] setStyle = new boolean[3];
style.getSelectedFlags(setStyle);
myCanvas.setFont(setFace, setSize, setStyle);
display.setCurrent(myCanvas);

}
}

}

class MyCanvas extends Canvas implements CommandListener{

Font Font;
FontTest midlet;
Command backCmd;
int face, size, style;

public MyCanvas(FontTest midlet){
this.midlet = midlet;
backCmd = new Command("重设", Command.BACK, 1);
addCommand(backCmd);
setCommandListener(this);
}

public void paint(Graphics g){

g.setColor(0xFFFFFF);
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(0);
g.setFont(Font.getFont(face, style, size));
g.drawString("Font Test", getWidth()/4, getHeight()/2, Graphics.TOP|Graphics.LEFT);

}

public void setFont(int face, int size, boolean[] selectedArray){

switch(face){
case 0: this.face = Font.FACE_SYSTEM; break;
case 1: this.face = Font.FACE_PROPORTIONAL; break;
case 2: this.face = Font.FACE_MONOSPACE; break;
}
switch(size){
case 0: this.size = Font.SIZE_LARGE; break;
case 1: this.size = Font.SIZE_MEDIUM; break;
case 2: this.size = Font.SIZE_SMALL; break;

}
if(selectedArray[0]){
style |= Font.STYLE_BOLD;
}
if(selectedArray[1]){
style |= Font.STYLE_ITALIC;
}
if(selectedArray[2]){
style |= Font.STYLE_UNDERLINED;
}
}

public void commandAction(Command c, Displayable d){
if(c == backCmd){
midlet.display.setCurrent(midlet.form);
}
}

}

请各位帮忙看看,谢谢。
...全文
78 点赞 收藏 3
写回复
3 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
LCLLL 2004-09-05
感谢,问题已经解决
回复
zcwhgj 2004-09-03
很明显,这是指定的启动类程序的路径或者名称不对.放在套件中应指定开始启动的类这里应该是:FontTest
回复
bobshi 2004-09-03
楼上正解。
回复
相关推荐
发帖
J2ME
创建于2007-09-28

1.3w+

社区成员

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