J2ME 调用Graphics的copyArea()抛出异常
IllegalStateException编译环境如下:
winXP SP2 + JBuilder2006
jdk1.5,j2mewtk2.2,全部JBuilder2006自带
源代码如下:
package iavatest;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import javax.microedition.lcdui.*;
import java.lang.*;
/**
* <p> Title: </p>
*
* <p> Description: </p>
*
* <p> Copyright: Copyright (c) 2007 </p>
*
* <p> Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class GraphicsTest extends MIDlet {
private Display display;
private MyGraphicsCanvas myGraphicsCanvas;
public GraphicsTest() {
display = Display.getDisplay(this);
myGraphicsCanvas = new MyGraphicsCanvas();
}
/**
* destroyApp
*
* @param _boolean boolean
* @throws MIDletStateChangeException
* @todo Implement this javax.microedition.midlet.MIDlet method
*/
protected void destroyApp(boolean _boolean) throws
MIDletStateChangeException {
}
/**
* pauseApp
*
* @todo Implement this javax.microedition.midlet.MIDlet method
*/
protected void pauseApp() {
}
/**
* startApp
*
* @throws MIDletStateChangeException
* @todo Implement this javax.microedition.midlet.MIDlet method
*/
protected void startApp() throws MIDletStateChangeException {
display.setCurrent(myGraphicsCanvas);
}
}
class MyGraphicsCanvas extends Canvas {
Image img;
public MyGraphicsCanvas(){
try{
img = Image.createImage( "/globe.png ");