×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Registered User
    Join Date
    May 2009
    Posts
    11

    Post J2ME IMAGE GHOSSTTTEEE

    Hi formers how are you?
    I'm here again with very simple and stupid problem, That I'm in trouble in getting the image from res folder
    Hoping good and brisk response from you guys
    a bundle of thankx for all of you......
    here is my source code I'm getting with....

    THIS IS THE MAIN MIDlet

    package imageeo;

    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.*;

    /**
    * @author 031-bscs-08
    */
    public class ImageMidlet extends MIDlet implements CommandListener{

    private Image image = null;
    private ImageClass canvasClass;

    public ImageMidlet()
    {
    }


    public void startApp()
    {
    canvasClass = new ImageClass();
    canvasClass.addCommand(new Command("Exit", Command.EXIT, 0));
    Display.getDisplay(this).setCurrent(canvasClass);
    }

    public void pauseApp() {}

    public void destroyApp(boolean unconditional) { }

    public void commandAction(Command c, Displayable d)
    {
    if(c.getCommandType() == Command.EXIT)
    {
    destroyApp(true);
    notifyDestroyed();
    }
    }
    }






    AND HERE IS THE CANVAS CLASS



    package imageeo;

    import java.io.IOException;
    import javax.microedition.lcdui.*;


    /**
    *
    * @author 031-bscs-08
    */
    public class ImageClass extends Canvas implements Runnable {


    private Image image = null;

    public ImageClass()
    {
    try {

    // I think the lurks are here that are pushing my application down
    this.image = Image.createImage("/res/Delete-icon.png");
    new Thread(this).start();

    } catch (IOException ex) {
    ex.printStackTrace();
    }
    }


    public void run()
    {
    while(true)
    {
    repaint();

    synchronized(this)
    {
    try {
    wait(50);
    } catch (InterruptedException ex) {
    ex.printStackTrace();
    }
    }
    }
    }

    protected void paint(Graphics g)
    {
    g.setColor(0xffffff);
    g.fillRect(0, 0, getWidth(), getHeight());

    if(image != null){
    g.drawImage(image, getWidth() / 2, getHeight() / 2, Graphics.HCENTER
    | Graphics.VCENTER);
    } else {
    g.setColor(0x000000);
    g.drawString("No image available", getWidth() / 2, getHeight() / 2,
    Graphics.HCENTER | Graphics.BASELINE);
    }
    }

    }

  2. #2
    Super Contributor
    Join Date
    Apr 2007
    Posts
    2,708

    Re: J2ME IMAGE GHOSSTTTEEE

    So what are you getting ? An exception or simply the "No Image AVailable" message ?
    Have you checked that thje filename is exactly like how you call it in the createImage method ? If i'm not mistaken it's case-sensitive so capital letters will make a difference...
    Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them.

  3. #3
    Registered User
    Join Date
    Sep 2009
    Location
    Bangalore, India
    Posts
    49

    Re: J2ME IMAGE GHOSSTTTEEE

    Quote Originally Posted by Tiger79 View Post
    So what are you getting ? An exception or simply the "No Image AVailable" message ?
    Have you checked that thje filename is exactly like how you call it in the createImage method ? If i'm not mistaken it's case-sensitive so capital letters will make a difference...
    Even the capital letter in the file extention may cause serious problem ... please check that once properly ..
    Regards
    Nilanchala

  4. #4
    Registered User
    Join Date
    May 2009
    Posts
    11

    Re: J2ME IMAGE GHOSSTTTEEE

    Yes your observation is exactally right I'm ending with "No Image AVailable" message. I gone through all the three times even Icopied the file name by editing its name and I'm sure about fileName and its case sensitivity even again I'm getting the same message..

    Okay Tiger there would'nt be any private message from now onward
    AND THANKS FOR REPLYING a lot of thanks.....

  5. #5
    Registered User
    Join Date
    May 2009
    Posts
    11

    Re: J2ME IMAGE GHOSSTTTEEE

    Yes I've checked that three times even then, the message is same... Thankx bro

  6. #6
    Super Contributor
    Join Date
    Apr 2007
    Posts
    2,708

    Re: J2ME IMAGE GHOSSTTTEEE

    ok,
    start by extending this part :
    catch (IOException ex) {
    ex.printStackTrace();
    }

    to something like
    catch (IOException ex) {
    System.err.println("Something wrong whilst creating Image : " + ex.toString()); //on emulator or if you are on device write it to a canvas or on a Alert
    }

    Simply don't use printStacktrace, it's of no use in j2me... try to catch the exceptions and write them somewhere you can read them !
    Last edited by Tiger79; 2010-06-23 at 15:56.
    Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them.

  7. #7
    Registered User
    Join Date
    May 2009
    Posts
    11

    Re: J2ME IMAGE GHOSSTTTEEE

    okay.. I'll do it and inform you soon.

  8. #8
    Registered User
    Join Date
    May 2009
    Posts
    11

    Re: J2ME IMAGE GHOSSTTTEEE

    doing in this way I'm getting this message "java.io.IOException"

  9. #9
    Registered User
    Join Date
    Oct 2009
    Location
    Noida
    Posts
    941

    Re: J2ME IMAGE GHOSSTTTEEE

    Quote Originally Posted by nasir031 View Post
    doing in this way I'm getting this message "java.io.IOException"
    Instead of this.image = Image.createImage("/res/Delete-icon.png"); line

    try this.image = Image.createImage("/Delete-icon.png");

    If it still fails:

    After packaging it in the JAR, rename it from .jar to .zip and view it with winzip -- and check if contains "Delete-icon.png" file - compare its character case and path with in the jar with one in code... it looks to be some mismatch because of which this is giving - IOException.
    Thanks,
    Ekta

  10. #10
    Registered User
    Join Date
    May 2009
    Posts
    11

    Re: J2ME IMAGE GHOSSTTTEEE

    Quote Originally Posted by ektasrv View Post
    Instead of this.image = Image.createImage("/res/Delete-icon.png"); line

    try this.image = Image.createImage("/Delete-icon.png");

    If it still fails:

    After packaging it in the JAR, rename it from .jar to .zip and view it with winzip -- and check if contains "Delete-icon.png" file - compare its character case and path with in the jar with one in code... it looks to be some mismatch because of which this is giving - IOException.
    aaaaaaaaaaaahhh Thankx a lot all of you, done it.
    Ekta, by doing "this.image = Image.createImage("/Delete-icon.png");" I've done it..Thankx

Similar Threads

  1. image compression in J2ME
    By rprabhune in forum Mobile Java General
    Replies: 3
    Last Post: 2009-09-14, 08:42
  2. image library for J2ME ?????
    By akshaychaudhari in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2009-01-30, 11:02
  3. threading image to a gif image ? (j2me)
    By intheworldofmyown in forum Mobile Java General
    Replies: 3
    Last Post: 2008-11-18, 17:31
  4. Displaying one image on top of another image in J2ME
    By amishra in forum Mobile Java General
    Replies: 13
    Last Post: 2008-11-17, 08:35
  5. How to convert a JPEG image to a PNG image using J2ME Code
    By hussain_afs in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2007-12-31, 16:48

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×