×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    Feb 2007
    Posts
    10

    Overloading of addCommand()

    Hi,

    Can anybody help me..m trying to overload addCommand(Command) so that I can insert it in my own menu.. but if I do this commandListerner does not listens or say CommandAction is not get called.. what might be the problem..

    Thanx

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

    Re: Overloading of addCommand()

    Are you calling the the addCommand() method of the superclass (super.addCommand())?

    shmoove

  3. #3
    Regular Contributor
    Join Date
    Sep 2006
    Location
    Delhi
    Posts
    77

    Re: Overloading of addCommand()

    Hi
    It seems that you forgot to associate your menu with setCommandListener.

    The data provided by you is very less. Can you post some piece of your code ?

  4. #4
    Registered User
    Join Date
    Feb 2007
    Posts
    10

    Re: Overloading of addCommand()

    This is that method..
    public void addCommand(Command cmd){
    if(cmdLeftSoftKey == null){
    cmdLeftSoftKey = cmd;
    }
    else if(cmdRightSoftKey == null){
    cmdRightSoftKey = cmd;
    }
    super.addCommand(cmd);
    }

    I called setcommandListener(this) in the constructor of class.
    If I removed super.addCommand(cmd) call it does not listens n if kept it, it invokes system menu...

  5. #5
    Registered User
    Join Date
    Dec 2005
    Location
    Brazil
    Posts
    1,884

    Re: Overloading of addCommand()

    Hi namrata,

    If I got it right I don't think it will work, the registration may be on the implementation code.

    Best,
    Juarez Alvares Barbosa Junior - Brazil

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

    Re: Overloading of addCommand()

    Quote Originally Posted by namrata
    This is that method..
    If I removed super.addCommand(cmd) call it does not listens
    That makes sense, since super.addCommand() is what will tell the framework that you added a Command.

    n if kept it, it invokes system menu...
    What do you mean by "it invokes system menu"? What system menu? And what do you want for it to happen?

    Also:
    Code:
    if(cmdLeftSoftKey == null){
      cmdLeftSoftKey = cmd;
    }
    else if(cmdRightSoftKey == null){
      cmdRightSoftKey = cmd;
    }
    When using Commands and the high-level UI you don't have real control over which softkey the Command will be added to. You can try to "influence" it with the Command type you add, but which side it will go is implementation dependent.

    shmoove

  7. #7
    Registered User
    Join Date
    Feb 2007
    Posts
    10

    Re: Overloading of addCommand()

    Hi shmoove,
    "When using Commands and the high-level UI you don't have real control over which softkey the Command will be added to. You can try to "influence" it with the Command type you add, but which side it will go is implementation dependent."

    exactly i want to decide that which command will go on which side. isn't it possible?

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

    Re: Overloading of addCommand()

    Not with the high-level UI. The control you have is limited to choosing the appropiate Command type when creating the Command. For instance a Command of type BACK or EXIT will usually go to the right softkey on Nokia phones.

    But this doesn't give you complete control: different phones will behave differently, and the number of Commands you add will also affect things.

    The only way to decide for yourself exactly which softkey does what is to use a full screen Canvas, and draw the "commands" yourself and handle the softkey presses in keyPressed()/keyReleased() (and then you run into the issue that softkey codes are not standardized).

    shmoove

  9. #9
    Registered User
    Join Date
    Feb 2007
    Posts
    10

    Re: Overloading of addCommand()

    k thanx shmoove

Similar Threads

  1. J2ME addCommand() Softkey Assignment
    By davidmanpearl in forum Mobile Java General
    Replies: 7
    Last Post: 2007-02-02, 18:29
  2. Replies: 9
    Last Post: 2005-03-01, 15:25
  3. addCommand throws null pointer
    By prakala in forum Mobile Java General
    Replies: 2
    Last Post: 2004-05-15, 13:18
  4. addCommand
    By marcgom in forum Mobile Java General
    Replies: 2
    Last Post: 2003-04-11, 00:25
  5. addCommand and setCommandListener
    By Nokia_Archive in forum Mobile Java General
    Replies: 1
    Last Post: 2002-05-24, 13:15

Posting Permissions

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