如何使用一个继承MIDlet的抽象类
大家好!
现在发现一个抽象类继承MIDlet,但运行后,自动推出了,然后报错:
java.lang.InstantiationException 想问下,MIDlet不是个抽象类吗?为什么还要写一个抽象类来继承它呢?
abstract public class SDAApplication extends MIDlet {
private static SDAApplication instance;
protected final SDAApplication Application = this;
private AppCanvas appCanvas = null;
private Graphics graphics = null;
private Display disp = Display.getDisplay(this);
private SDAForm foucsedForm = null;
private SDAForm mainForm = null;
public SDAInputPanel inputPanel = new SDAInputPanel();
private Vector dispList = new Vector();
private SDAMessageBox msgBox;
public static final int SKIN_STANDARD = 0;
public static final int SKIN_POPULAR = 1;
private SDASkins Skins = null;
private int skin = SKIN_STANDARD;
private boolean doubleBuffered = true;
private boolean ctrl3d = false;
private Timer runOneceTimer = new Timer();
public SDAApplication() {
instance = this;
this.appCanvas = new AppCanvas();
this.appCanvas.setFullScreenMode(true);
this.disp.setCurrent(appCanvas);
}
public final void setSkin(int skin) {
this.skin = skin;
if (skin == SKIN_POPULAR) {
Skins = null;
Skins = SDASkins.CreateSkins();
}
}
public final void setDoubleBuffered(boolean doubleBuffered) {
this.doubleBuffered = doubleBuffered;
}
public void setCtrl3d(boolean ctrl3d) {
this.ctrl3d = ctrl3d;
}
public void setMainForm(SDAForm mainForm) {
this.mainForm = mainForm;
}
public final boolean isDoubleBuffered() {
return this.doubleBuffered;
}
public final boolean hasPointer() {
return this.appCanvas.hasPointerEvents();
}
protected final Graphics GetGraphics() {
return this.graphics;
}
protected final Canvas GetCanvas() {
return this.appCanvas;
}
protected SDAForm getFoucsedForm() {
return foucsedForm;
}
public int getSkin() {
return skin;
}
public boolean isCtrl3d() {
return ctrl3d;
}
public static SDAApplication GetInstance() {
return instance;
}
public void MessageBox(String Caption, String Text, int flags) {
MessageBox(Caption, Text, flags, null);
}
public void MessageBox(String Caption, String Text, int flags,
MsgBoxCloseEvent closeEvent) {
msgBox.closeEvents.addElement(closeEvent);
msgBox.caption = Caption;
msgBox.txtLabel.setText(Text);
msgBox.button1.setVisible(false);
msgBox.button2.setVisible(false);
int btnFlags = flags % 10;
switch (btnFlags) {
case SDAConsts.MB_OK: {
msgBox.button1.setVisible(true);
msgBox.button1.setText("确定");
break;
}
case SDAConsts.MB_YESNO: {
msgBox.button1.setVisible(true);
msgBox.button2.setVisible(true);
msgBox.button1.setText("是");