Hi pavanragi,
What if you call
Code:
form2.setBackCommand(m_backCommand)
?
I have tried the following code below which switches between two Forms by clicking on the Back Command
Code:
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import com.sun.lwuit.Command;
import com.sun.lwuit.Display;
import com.sun.lwuit.Form;
import com.sun.lwuit.events.ActionEvent;
import com.sun.lwuit.events.ActionListener;
public class Midlet
extends MIDlet
implements ActionListener {
Command switchForms = new Command("switch");
Form form1;
Form form2;
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
}
protected void pauseApp() {
}
protected void startApp() throws MIDletStateChangeException {
Display.init(this);
form1 = new Form("Form 1");
form2 = new Form("Form 2");
form1.addCommand(switchForms);
form1.addCommandListener(this);
form2.addCommand(switchForms);
form2.addCommandListener(this);
form1.setBackCommand(switchForms);
form2.setBackCommand(switchForms);
form1.show();
}
public void actionPerformed(ActionEvent ae) {
if(form1.isVisible()) {
form2.show();
System.out.println("Back to Form 2");
}
else {
form1.show();
System.out.println("Back to Form 1");
}
}
}
and I couldn't find any issues, even after several clicks on Back. Let us know, if this doesn't solve your problem.