J2ME的代码从Eclipse拷入Jbuilder2005中运行不出来
我这里有一个J2ME的代码,在Eclipse4.2里可以模拟出来.因为种种原因,我想把它移植到Jbuilder2005中去,于是在Jbuilder中新建一个工程及相关Java类,将代码拷入,代码没有报错,但在模拟器里出不来,请各位大虾指教如何是好?谢谢
觉得Eclipse和Jbuilder的Midlet和Convas文件相当不一样.(其它的Java的文件应该差不离)
被覆盖的Jbuilder 的代码:
MineMidlet.java文件:
package mine;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class MineMidlet extends MIDlet
{
static MineMidlet instance;
MainCanvas displayable = new MainCanvas();
public MineMidlet()
{
instance = this;
}
public void startApp()
{
Display.getDisplay(this).setCurrent(displayable);
}
public void pauseApp()
{
}
public void destroyApp(boolean unconditional)
{
}
public static void quitApp()
{
instance.destroyApp(true);
instance.notifyDestroyed();
instance = null;
}
}
MainConvas文件:
package mine;
import javax.microedition.lcdui.*;
public class MainCanvas extends Canvas
{
public MainCanvas()
{
try
{
jbInit();
}
catch(Exception e)
{
e.printStackTrace();
}
}
private void jbInit() throws Exception
{
// add the Exit command
addCommand(new Command("Exit", Command.EXIT, 1));
}
protected void paint(Graphics g)
{
/** @todo Add paint codes */
}
}
原Eclipse代码
MineMidlet.java文件:
public class MineMidlet extends MIDlet {
private static MainCanvas m_MainCanvas;
public static MineMidlet m_Midlet;
public MineMidlet() {
super();
m_Midlet = this;
}
protected void startApp() throws MIDletStateChangeException {
try{
m_MainCanvas = new MainCanvas();
}
catch (Exception ex){ }
Display.getDisplay(this).setCurrent(m_MainCanvas);
}
protected void pauseApp() {
m_MainCanvas.Stop();
}
protected void destroyApp(boolean arg0)throws MIDletStateChangeException {
m_MainCanvas.Stop();
}
}
MainConvas文件:
package mine;
public class MainCanvas extends GameCanvas implements Runnable{
public MainCanvas( ){
super(false);
try{
}
catch(Exception exception){} ;
Start();
}
public void Start(){
m_bRunning = true;
Thread thread = new Thread(this);
thread.start();
}
public void run() {
}
public void Stop(){
m_bRunning = false;
}
public void Input(){
}
public void Logic(){
}
public void Paint(){
Graphics g = getGraphics();
}
}
------解决方案--------------------