读书人

Uncaught exception java.lang.NoClas

发布时间: 2014-01-26 14:39:36 作者: rapoo

Uncaught exception java.lang.NoClassDefFoundError: Wireless/test/MyCan-放在一个Suite中运行时异常

代码如下:

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){
        

读书人网 >Java Exception

热点推荐