首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Exception >

J2ME调用Graphics的copyArea()抛异常java.lang.IllegalStateException

2014-01-26 
编译环境如下: winXP SP2 + JBuilder2006 jdk1.5,j2mewtk2.2,全部JBuilder2006自带 源代码如下: package ia

编译环境如下:
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 ");
} catch(Exception e){
}
}
protected void paint(Graphics g){
g.setColor(255,255,255);
g.fillRect(0,0,getWidth(),getHeight());
g.setColor(0,0,0);

g.drawLine(5,10,55,60);
g.fillRect(65,10,50,50);
g.drawRect(125,10,50,50);
g.drawRoundRect(185,10,50,50,10,10);
g.fillRoundRect(5,70,50,50,10,10);         

热点排行