blackberryjava-melwuitlwuit-buttonlwuit-command

back button in lwuit with blackberry


I developed an mobile application using LWUIT and it works fine in devices with J2ME. I want to run the same application in Blackberry also. I saw some samples about LWUIT on Blackberry but none of them answered me.

How can I handle the back button on the device to make back movements? What I mean is that, when I press the back button on the device, I want the application move to the previous screen.

I used regular buttons to handle back movements just for now, but when we think of user side, it is not so friendly.

I dont want to use commands like I did in j2ME app., because it seems not so nice.

Is there anyone who can solve it?


Solution

  • Set a particular back command to the form. For example,

    Command backCmd = new Command("Back"){
    
    public void actionPerformed(ActionEvent evt) {
       previousForm.show();
      }
    };
    
    currentForm.setBackCommand(backCmd);