×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Regular Contributor
    Join Date
    Sep 2008
    Posts
    158

    ItemCommandListener prob

    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */

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

    /**
    * @author selvakumar
    */
    public class item_demo extends MIDlet implements ItemCommandListener{
    Display display;
    Form form;
    Form mainform;
    Command back;
    Command cmd;
    Command click;

    ImageItem it;
    Image img;
    public item_demo()
    {
    form=new Form("hello") ;
    mainform=new Form("form2");

    cmd=new Command("simply",Command.OK,1);
    click=new Command("click",Command.OK,1);
    back=new Command("BACK",Command.OK,1);

    form.addCommand(click);

    mainform.addCommand(back);
    try{
    img=Image.createImage("untitled.png");
    it=new ImageItem(null,img,ImageItem.LAYOUT_CENTER,null,ImageItem.PLAIN);
    form.append(it);
    it.setDefaultCommand(cmd);
    it.setItemCommandListener(this);

    }
    catch(Exception e)
    {

    }


    }
    public void startApp() {
    display=Display.getDisplay(this);
    display.setCurrent(form);
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }

    public void commandAction(Command c, Item d)
    {
    if(c==cmd)
    {
    display.setCurrent(mainform);
    mainform.append("gud morg");
    }
    else if(c==back)
    {
    display.setCurrent(form);
    }

    }
    }

  2. #2
    Regular Contributor
    Join Date
    Sep 2008
    Posts
    158

    Re: ItemCommandListener prob

    not able to view the image

  3. #3
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: ItemCommandListener prob

    That's strange... I tried your code and it worked. I saw the image in the first form, clicked on "simply" and was taken to the second form which had the words "gud morg".

  4. #4
    Registered User
    Join Date
    Sep 2008
    Posts
    4

    Re: ItemCommandListener prob

    Quote Originally Posted by jselvakumar26071988 View Post
    not able to view the image
    Seems to work for me also. May be its a problem for specific model.

  5. #5
    Regular Contributor
    Join Date
    Sep 2008
    Posts
    158

    Re: ItemCommandListener prob

    image is located under \src\.......
    is dat correct?
    not able to c de image....

  6. #6
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: ItemCommandListener prob

    Quote Originally Posted by jselvakumar26071988 View Post
    image is located under \src\.......
    is dat correct?
    not able to c de image....
    Yes. That's where it's supposed to be. I tried your exact code with the image in the src folder and it worked.

  7. #7
    Regular Contributor
    Join Date
    Feb 2008
    Posts
    174

    Re: ItemCommandListener prob

    i got a same problem ..convert image or if possible change it..it may be corrupted

Similar Threads

  1. CommandListener / ItemCommandListener problem
    By marshallarts in forum Mobile Java General
    Replies: 0
    Last Post: 2005-06-16, 03:33
  2. Series 80 file handling prob
    By vaibhavsh83 in forum Mobile Java General
    Replies: 0
    Last Post: 2005-04-11, 14:34
  3. DKU-2 prob or pc suite?
    By eugene_kee in forum Symbian
    Replies: 2
    Last Post: 2004-08-02, 16:12
  4. prob in downloading jar file in 7650
    By ajay_sipl in forum WAP Servers
    Replies: 2
    Last Post: 2002-08-21, 09:03

Posting Permissions

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