Sorry i fI interphere in this discussion, or anyway reopen it, but I have practically the same problem, but with a little difference and I was wondering whether there might be a different solution, rather than starting a new thread.
If I have a midlet, and would like to add a login component to it, could I just create the menus and logic of the login in a separate class (not midlet, just normal class) and plug it in the existing midlet just by passing the display to this class and back to the midlet when I am finished with the login?
I tried and I can get it to work, meaning the id I pass the display object from the midlet to the login class, I can actually control the screen from the login class, but then I do not know how to give the control back to the midlet......
and whether other things like record management would work)
Code:
protected void startApp() throws MIDletStateChangeException {
display=Display.getDisplay(this);
LoginModule log=new LoginModule(this.display);
log.start();
nextMenuInMidlet();? //do not know how to continue from this point when login is done....
and the login class would look like:
Code:
public class LoginModule implements CommandListener {
Display display;
TextBox box;
private Command ok=new Command("ok", Command.OK, 1);
private Command ok2=new Command("ok2", Command.OK, 1);;
LoginModuler(Display d){
this.display=d;
}
public void menuTest(){
box=new TextBox("Start","External menu",50,0);
box.addCommand(ok);
box.setCommandListener(this);
display.setCurrent(box);
}
public void menuTest2(){
box=new TextBox("Start","External menu 2",50,0);
box.addCommand(ok2);
box.setCommandListener(this);
display.setCurrent(box);
}
public void commandAction(Command arg0, Displayable arg1) {
if (arg0.getLabel().equals("ok")) {
menuTest2();//end();
}
if (arg0.getLabel().equals("ok2")) {
menuTest();//end();
}
}
}
Is there any way to accomplish this?