Search code examples
java-melwuitcodenameone

Run particular command on particular button's action listener


I have a form which has 4 commands says Action1, Action2, Action3, Action4. Theses commands runs fine.

Now i have a button says runCommand which have to call Action1 command. how can we do it. that run a command on action of particular button's action listener .


Solution

  • While invoking actionPerformed will work, there is a better and more correct way:

    Display.getInstance().getCurrent().dispatchCommand(cancel, new ActionEvent(form, BACK_COMMAND_ID));