×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Regular Contributor
    Join Date
    Mar 2007
    Posts
    88

    Problem with commands

    Hi guys!
    I have a small problem using the commands, I have 2 forms in different classes and when I am in the second form I would like to be back in the first form....

    this is the code:

    I have 2 files: midlet and another file


    public class midlet extends MIDlet implements CommandListener
    {
    private Display display;
    private Form form;
    private Command next,;
    public void startApp()
    {
    display = Display.getDisplay(this);
    Form form = new Form("");
    next = new Command("Next",Command.ITEM,1);
    form.addCommand(next);
    form.setCommandListener(this);
    display.setCurrent(form);
    }

    public void pauseApp()
    {
    }

    public void destroyApp(boolean unconditional)
    {
    }

    public void commandAction(Command c, Displayable displayable)
    {
    if(c==next)
    OtherClass c = new OtherClass(display,form);
    c.Method();

    }
    }




    in OtherClass I did:

    public class OtherClass
    {
    private Display display;
    private Form form, form2;
    private Command back;
    public InsertNewUser(Display d, Form f)
    {
    display=d;
    form=f;
    }

    private void Method()
    {
    form2 = new Form("");
    back = new Command("back",Command.Back,0);
    form2.addCommand(back);
    display.setCurrent(form2);
    form2.setCommandListener(new CommandListener( )
    {
    public void commandAction(Command c, Displayable d)
    {

    if (c==back)
    {
    display.setCurrent(form);
    }
    });

    }



    But when i press back the emulator doesn't cause any action....


    Could someone help me please?

    thanks
    antonio

  2. #2
    Registered User
    Join Date
    Mar 2007
    Posts
    46

    Re: Problem with commands

    public class OtherClass implements CommandListener

  3. #3
    Super Contributor
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    2,280

    Re: Problem with commands

    He's using an anonymous inner class for the listener so OtherClass doesn't need to implement it.

    Put some debugging statements in your code so you can see where exactly it is failing. Does it reach commandAction()? Does it go into the if block?

    shmoove

Similar Threads

  1. Problems sending SMS with AT commands
    By bow24el in forum General Messaging
    Replies: 4
    Last Post: 2007-02-15, 04:46
  2. PROBLEM IN DISPLAYING MENU COMMANDS
    By pistha in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2006-09-21, 15:17
  3. problem in carbide
    By sameerbkamble in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 1
    Last Post: 2006-07-06, 16:48
  4. About 6230 Bt Problem
    By eerkek in forum Bluetooth Technology
    Replies: 17
    Last Post: 2005-02-08, 12:33
  5. 7210 Silent Problem
    By MarkMckim in forum Mobile Java General
    Replies: 1
    Last Post: 2003-03-18, 12:36

Posting Permissions

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