command listener problems in MIDP

I am trying to get my Form to react on incoming commands but my commandlistener doesnt work.

I extend the class Form and implements the commandListener interface, like this

public class ReportForm extends Form implements CommandListener{

...

}

I implement the commandAction method like

public void commandAction(Command c,Displayable s){

append("hello!");

}

and in my constructor i set the commandListener :

setCommandListener(this);

But it seems that when I press a button the commandAction() method isn't called. Is there something else i should do to get it to work?

/Anders

[664 byte] By [d98al] at [2007-9-26 3:14:02]
# 1

Hi,

Please add this statement in your ReportForm constructor, just before SetCommandListener(this).

addCommand(new Command("Ok", Command.OK, 1));

Then the time you click ok, your string will be displayed. The reason is that the commandAction will not be called unless the command click event is fired.

Best wishes!

Shen Bo

bo_shen at 2007-6-29 11:23:55 > top of Java-index,Java Mobility Forums,Java ME Technologies...