Skip to main content

Command-ID

2 replies [Last post]
transducer
Offline
Joined: 2007-10-14
Points: 0

hi,

a little question about command-id's - i detect a difference in the follow code:

-code---------------------------------------------------------

Command cmd = new Command("Exit", 4);

form.addCommand(cmd);
form.addCommand(new Command("Help"),5);

...

ActionListener command_listener = new ActionListener() {

public void actionPerformed(ActionEvent ae) {

System.out.println("name: " +
ae.getCommand().getCommandName() +
" id: " +
ae.getCommand().getId());

}
};

form.setCommandListener(command_listener);

-output:------------------------------------------------------------

name: Exit id: 4
name: Help id: 0

-----------------------------------------------------------------------

why is there a 0? is that correct? it normally must be a 5!?! (or rather i ecpect a 5...)

thanks,
transducer

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Shai Almog

Hi,
you misplaced the comma and 5 you wrote:
addCommand(new Command("Help"), 5);

Rather than:
addCommand(new Command("Help", 5));

Thanks,
Shai.

> hi,
>
> a little question about command-id's - i detect a difference in the
> follow code:
>
> -code---------------------------------------------------------
>
> Command cmd = new Command([b]"Exit", 4[/b]);
>
> form.addCommand(cmd);
> form.addCommand([b]new Command("Help"),5[/b]);
>
> ...
>
> ActionListener command_listener = new ActionListener() {
>
> public void actionPerformed(ActionEvent ae) {
>
> System.out.println("name: " +
> ae.getCommand().getCommandName() +
> " id: " +
> ae.getCommand().getId());
>
> }
> };
>
> form.setCommandListener(command_listener);
>
> -output:------------------------------------------------------------
>
> name: Exit id: [b]4[/b]
> name: Help id: [b]0[/b]
>
> ----------------------------------------------------------------------
> -
>
> why is there a 0? is that correct? it normally must be a 5!?! (or
> rather i ecpect a 5...)
>
> thanks,
> transducer
> [Message sent by forum member 'transducer' (transducer)]
>
> http://forums.java.net/jive/thread.jspa?messageID=284512
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
For additional commands, e-mail: users-help@lwuit.dev.java.net

transducer
Offline
Joined: 2007-10-14
Points: 0

oh my god... what a simple mistake!

many thanks.