j2me编程中drawImage函数使用无法显示图片
编译通过,没有抛出异常,代码如下:canvas类:packageGraphics;importjavax.microedition.lcdui.*;publicclass...
编译通过,没有抛出异常,代码如下:canvas类:package Graphics;import javax.microedition.lcdui.*;public class Mycanvas extends Canvas{private Image image;private int x =this.getWidth();private int y =this.getHeight();public Mycanvas(){try{image = Image.createImage("/L.png");}catch(Exception ex){System.out.println(ex);}}public void paint(Graphics g){//g.setColor(25,25,36);//g.fillRect(0, 0, x, y);g.drawImage(image, x,y , Graphics.LEFT|Graphics.TOP);System.out.println("hehe");}}主类package Graphics;import javax.microedition.midlet.MIDlet;import javax.microedition.midlet.MIDletStateChangeException;import javax.microedition.lcdui.*;public class test extends MIDlet {private Display display;private Mycanvas mycanvas;public test() {display = Display.getDisplay(this);mycanvas = new Mycanvas();}protected void startApp() throws MIDletStateChangeException {display.setCurrent(mycanvas);}protected void destroyApp(boolean arg0) throws MIDletStateChangeException {}protected void pauseApp() {}}
展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询