1 Reply Latest reply: Jun 28, 2012 4:34 AM by VANPERSIE RSS

    J2ME  Unable to load   image

      I am unable to load any image on J2ME ,I made many trails to load an image of 48*48 size and png format but I failed.
      although the image on the same folder of the class .
      I need help please
      import java.io.IOException;
      import javax.microedition.midlet.*;
      import javax.microedition.lcdui.*;
      public class ImageItemExample2 extends MIDlet{
        private Display display;
        public void startApp(){
        display = Display.getDisplay(this);
        display.setCurrent(new ImageCanvas());
        public void pauseApp(){}
        public void destroyApp(boolean unconditional){
      class ImageCanvas extends Canvas{
        private Image image1, image2, image3;
        public ImageCanvas(){
      /*  image1 = Image.createImage("c://Documents and Settings//user//My Documents//NetBeansProjects//MobileApplication1//src//hello/cartoon.jpeg");
        /***image2 = Image.createImage("c://Documents and Settings//user//My Documents//NetBeansProjects//MobileApplication1//src//hello/girl.gif");*/
        image3 = Image.createImage("man.png");
        }catch (IOException e){
        throw new RuntimeException("Unable to load Image: "+e);
        public void paint(Graphics g){
        g.fillRect(0, 0, getWidth(), getHeight());
      /*  g.drawImage(image1, 0, 0, Graphics.TOP | Graphics.LEFT);
       /* g.drawImage(image2, getWidth() / 2, getHeight() / 2, Graphics.CENTER
         | Graphics.VCENTER);*/
        g.drawImage(image3, getWidth(), getHeight(), Graphics.BOTTOM
         | Graphics.RIGHT);
      Edited by: VANPERSIE on Jun 28, 2012 10:42 AM
        • 1. Re: J2ME  Unable to load   image
          For check also I tried [this link |http://docs.oracle.com/javase/tutorial/displayCode.html?code=http://docs.oracle.com/javase/tutorial/uiswing/examples/components/BorderDemoProject/src/components/BorderDemo.java] with it's icon but
          on runtime I show a message:-
          Couldn't find file: C:\Program Files\Android\android-sdk\iconic\src\wavy.gif
           ImageIcon icon = createImageIcon("C:\\Program Files\\Android\\android-sdk\\iconic\\src\\wavy.gif" ,"");
          Edited by: VANPERSIE on Jun 28, 2012 12:33 PM

          Edited by: VANPERSIE on Jun 28, 2012 12:33 PM