以下这段程序单独编译运行通过,但放在一个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);
}
}
}
请各位帮忙看看,谢谢。