以下这段程序单独编译运行通过,但放在一个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);
}
}

}

请各位帮忙看看,谢谢。
...全文
114 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
LCLLL 2004-09-05
  • 打赏
  • 举报
回复
感谢,问题已经解决
zcwhgj 2004-09-03
  • 打赏
  • 举报
回复
很明显,这是指定的启动类程序的路径或者名称不对.放在套件中应指定开始启动的类这里应该是:FontTest
bobshi 2004-09-03
  • 打赏
  • 举报
回复
楼上正解。

13,100

社区成员

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

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