Button with Command adds Forms as CommandListener
I found a problem in my code because I was not aware of the following, so I like to share it:
When I create a normal Button from a Command, with "new Button (new Command("Text", Cmdid)),"
and do all action handling in my Form, so do an button.addActionListener(form),
then the actionPerformed() method of the Form is called twice!
The button calls its action listener,
and when action is not marked as consumed,
the button calls automatically the action handling of the form it is part of.
Of course a solution is to always add ae.consumed() after you have handled the event. But because not doing it has worked so far, and because it makes the event handling a little more verbose, I had not done it.
Another solution is not to do the button.addActionListener(form). But it is sometimes not obvious when to add it and when not.
If somebody from LWUIT team reads ist, I think there should be more information about event handling in the "Lightweight UI Toolkit Developer's Guide". Also a line in the SDK docu for Button(Command) about the automatic routing of actions to the form is missing.
I use Lwuit 1.4. as it seem to be the latest official release.